Thread: Printing into a file

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    39

    Question Printing into a file

    Hi I have a particularly creepy problem eating my head from quitea few days.

    I have a large array of size say 3000, at the end of the program i have certain computations done and stored as elements of this array, now i want to print the elements from this array into a file.

    I am using fprintf , and using a while loop to print until the length of the string is zero.
    the problem is that i get empty lines added automatically in between and also that sometimes the data is broken into 2 lines when displayed. please help!
    Code:
    while(strlen(StringCup[iz])!=0)
    {
    	fprintf(f1,"%s\n",StringCup[iz]);
    	printf("%s\n",StringCup[iz]);
    	iz++;
    }

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Post a compilable example. Chances are, though, some of the strings have the character '\n' embedded in them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

Tags for this Thread