Constructing a different .txt using C++

Hello, but due to my programming skills lacking "skill", I have no clue how to, if, it is possible for the program, when running, to produce a separate .txt document...

For instance, I would like to accomplish
-Records everything you put into it
-Stretch out the output (explanation below) *


* Where fputs, it seems only a limited amount before Word Wrap comes in and distorts it, would like to see if:
1
2
fputs ("Log was sucessfully
constructed",pFile);



Without breaking it,





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int thirdMain()
{
    system("PAUSE");
    

    FILE * pFile;
  pFile = fopen ("Datalog.txt","w+");
  if (pFile!=NULL)
  {
    fputs ("Log was successfully constructed",pFile);
    fputs ("Test 01",pFile);
    fclose (pFile);
  }
system("PAUSE");
return 0;
}
humm i am not sure what you mean so here is a guess

if you read the manual fputs adds a new line character at the end of the string

1
2
3
4
5
fputs( "something", pFile);

will yield

something<NL>


I would suggest for simplicity to use fprintf() instead, there you can indicate if a newline should be output:

1
2
fprintf( pFile, "Log was successfully constructured" ); 
fprintf( pFile, "Test 01" );


will come on the same line

but

1
2
fprintf( pFile, "Log was successfully constructured\n" ); 
fprintf( pFile, "Test 01\n" );


would give the same out as with fputs

HTH
Topic archived. No new replies allowed.