My Tech notes: C Function to add line in a file
Subscribe

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Sunday, October 5, 2008

C Function to add line in a file

C Function to add line in a file

int add_line(char *cfg_cmd)
{
int ret=-1;

FILE *fp;

fp = fopen("test.txt", "a+");
if(fp != NULL)
{
fprintf(fp,"%s",cfg_cmd);
fclose(fp);
ret = 0;
}
else
{
ret = -1;
fclose(fp);

}

return ret;
}

No comments:

Post a Comment