2 things.

This is a discussion on 2 things. within the C++ Programming forums, part of the General Programming Boards category; Hi, I need help with 2 things.
1st thing is I want to make a header to hold my #includes ...

2 things.

Hi, I need help with 2 things.

1st thing is I want to make a header to hold my #includes and ints,floats,exc. When I do this it works ok with just my #includes out in this file, but when I move my ints(so on) into it also, it doesnt work at all. It gives me a error about something inside the file and says other things don't work.

2end is: I want this line of code to refresh it self. Its a clock so I know the time, but it only tells me ones unless I reloop it when I hit enter or something.

1. Not sure what you mean, but if you want to declare object such as int in a header file you need to preceed it with extern keyword, then declare it again in one, and only one, *.c or *.cpp file without extern

Code:

// *.h file
extern int foo;

2. If you want the time to keep ticking on the screen then you need to do that in another thread. create another thread, and an infinite loop in that thread that gets and displays current time once each second.

See, the main program calls on this file for the ints and includes. Mine on the other hand will only work with includes like this, and will give a error when I put my ints into it. Thes wont with its main program.

2en thing. Ok, thanks but I cant seems to get that to work right with out stoping my 1st inft. loop. It kinda needs to be refresh with in my code. Maybe if I show more you will see.

as for the time, here is an example -- it may not give you the complete desired output, but its a start. You will probably have to move the cursor to a specific location then display the text. Here is some example code. Click Components link at the top of the page, then scroll down and find Console Object.

Hmm,Thanks. I got some questions on the thread making tho. I've been looking it up so I understand what you did, but didnt finde much. (i'm still perty new to this stuff) I try puting what you had in my code and it didnt come out right... Maybe I have this wrong or something. Ok to start from what I know now so I can understand it more: threads hold what your doing, but! seeing as I have a inft. loop right off in my thread and want to put another in it will stay in 1st inft. loop till its done (witch is never).
Now with another thread, one can do my main program, and the other can do the time. The time one should be 1st to show the time (witch is where I want it so it shows 1st)

if you are writing a dialog, then you want to create the dialog if the program's main thread (where main() or winmain() exists), then in the second thread to the time stuff and display the time in a text control of the dialog. In my example, ThreadProd() is the entry point of the new thread, similar to main() is the entry point into the program itself. Programs may contain as may threads as desired -- there is no theorical limit, but there is a practial limit. Games use a lot of threads -- all those little critter you see moving all around are in different threads. You don't have to name the new thread "ThreadProc" -- you can name it anything you wish and can even be a static method of a c++ class.

Ok, I thought that was what it was, wasnt sure (why you name the thread and the creat threat thing). You kinda got me lost on what you were saying tho, sorry not to be rud or anything.

if you are writing a dialog, then you want to create the dialog in the program's main thread (where main() or winmain() exists), then in the second thread to the time stuff and display the time in a text control of the dialog. In my example, ThreadProd() is the entry point of the new thread, similar to main() is the entry point into the program itself.

Ok, thanks I kinda get that, but I dont get something here tho too. So your example is a new thread right? Hmm it could be how I think the new thread should work maybe thats stoping me from understand. This is how I think the new thread works also.
~main program, things after ~int main(void)~>|
this is the 1st thread, where I end int main~> / \ <~this is the 2end thread where I start after ending int main