0
#include<stdio.h>

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 */
        }
        
    }
    fclose(point);
    getchar();
}

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.....
plz
help

plzzzzz.......][/

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

8
Contributors
7
Replies
10
Views
7 Years
Discussion Span
Last Post by Ajinkya Naik
0

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 by thomas_naveen: n/a

0

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.
Now
putc(others[indexer],point);
//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

0

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()

0

/*
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.
*/

#include<conio.h>
#include<stdio.h>

void main()
{
for(i=0;i<4;i++)
{
for(j=0;j<=i;j++)
printf("0");
printf("\n");
}
getch();
}

Edited by prvnkmr449: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.