#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    60
    Rep Power
    12

    Return Character


    Okay, here is what I am doing. I am currently able to save a string into a file. The problem is when I save a second string to the file the two strings are tight next to each other. I need them to be on seperate lines. So my questions is this, how do you either append the end of line signal to the first string. Or send the End of Line signal right afterwards.
    I attempted to use the VK_RETURN function, but that is not working. There is a possibility I am implementing that function incorrectly. Okay, thanks for the help
    Sincerely,
    Ronald
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,254
    Rep Power
    2222
    I assume that this is to a text file.

    Code:
    char aString[MAXSTRINGSIZE];
    
    /* code in which a string has been written to aString */
    /* now write it to file pointer to by FILE *fp */
    fprintf(fp,"%s\n",aString);
  4. #3
  5. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    assuming the first string is named s1, do one of the following before writing it to the file:
    strcat(s1, "\n");
    or
    s1+="\n";
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    60
    Rep Power
    12

    Thanks


    just wanted to say, thanks alot. I had tried something like that, but it did not work. I did not think it would be that simple.
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,254
    Rep Power
    2222
    Oops! I forgot the text-file-specific functions fputs and fgets. I do primarily embedded programming, so I don't do that much file I/O.

    You still need to append the '\n' with fputs, but fgets will read in one entire line of text up to and including the '\n'.

IMN logo majestic logo threadwatch logo seochat tools logo