int main()
    FILE *point;
    char others[35];
    int indexer,count;
    strcpy(others,"Additional lines.");
    point = fopen("tenlines.txt","a"); /* open for appending */
    for (count = 1;count <= 10;count++) 
        for (indexer = 0;others[indexer];indexer++)
            putc(others[indexer],point); /* output a single character */
            putc('\n',point); /* output a linefeed */

plz i cant understand the inner for loop in above programme...
[That indexer one]...
i hav already studied about fopen and other I/O functions...
but only cant understand the inner loop....
plzzzzzzzzzzzzzzzzzzzzzzzzz need ur help....
plz temme the full mechanism of the inner loop.....


Edited 6 Years Ago by WaltP: 13 posts and you can't use CODE Tags properly yet?

Take alook at the strcpy function.

The C string will have a terminating null character.

In the for loop,

for (indexer = 0;others[indexer];indexer++)

when the index (indexer) reaches the index of this terminating null character , the loop will exit.

Please use the CODE tags properly.

Edited 6 Years Ago by thomas_naveen: n/a

in the above program
Others[]- an array which is storing a string "Additional lines"

Now this string "Additional lines" has to be put into tenlines.txt file.
point variable points to the cursor position of the file "tenlines.txt".
Two integers indexer and count are used in for loop.

for (count = 1;count <= 10;count++)
//is used for counting exactly two lines

for (indexer =0;others[indexer];indexer++)

//used for incrementing the array other[], from 0 to the last word it can accomodate.
//putting the strings or values from others to point variable that actually points to the cursor position of tenlines.txtr files.

So basically this program copy your string and get it written into a text file

The inner loop simply put additional with new line between each char.because strcpy() simply add null string at the end of "Additional lines". That is"Additional\0lines".
so the "lines" omitted by strcpy()

Name : Praveen Kr.
E-mail: prvnkmr449@gmail.com
Mobile no.:+918808130075

please reply if my post is help for u or if any problem on c ask me on my email.


void main()

Edited 6 Years Ago by prvnkmr449: n/a

This question has already been answered. Start a new discussion instead.