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;
}
Comments