What I´m suposed to archiev wwith this Code is 1st: generate primal numbers, check; 2nd: stop the while Loop with Esc., check; 3rd Save all generated numbersnumbers in a folder, and this is the Point where I´m lost, I looked trough the internet tried a bunch of Things but I can´t help it :( would be cool if someone has an Idea.
I'm not at all sure you have a proper grasp of your assignment: For example, your while-loop isn't very effective for the over-all functioning of your program.
I would suggest that the intent of the while-loop is to control the other parts of your program; i.e.,
vector< int > Primals;
int number = 0;
while( exit == false )
{
/* Generate primal (primal?) numbers: */
number = PrimalFunction(); /* You have to write this one! */
/* Save the number into a vector: */
Primals.push_back( number );
if( GetAscynKeyState( VK_ESCAPE ) )
exit = true;
} /* while( exit == false ) */
/* The rest of this is just my pseudo code for you to fill in: */
/* Now save your generated numbers into a folder (folder?): */
/* Add code to check for the existence of your directory: */
/* If the folder doesn't exist, create it: */
/* Now create an output file in the directory: */
/* Write the created numbers to the output file: */
vector< int >::iterator itr;
for( itr = Primals.begin(); itr != Primals.end(); ++itr )
{
Output << *itr << endl;
} /* for( itr != Primals.end() ) */
thanks first,
for what in my code should I replace with your code?
What I just noticed, may we have a lil´miss understanding, if you run my Code, the Screen will fill with a lot of numbers, I want to get them all into the folder, not only a single one, don´t ask me why^^ I don´t know either :D but the teacher want what he want and explains nothing^^
If you have coded the earlier things I suggested, this part would be trivial. Since it looks like you are writing on Unix, look at the system functions opendir(), readdir() etc (man directory(3C). That will get you your directory (folder) creating code.
To write to a file, there are many examples out there.