i have the following statement:-
printf("%-9s %5s %10s %4s %9s %18s %9s %10s %s\n",
"COMMAND",
"PID",
"USER",
"FD",
"TYPE",
"DEVICE",
"SIZE/OFF",
"NODE",
"NAME");
i have the following declaration global:-
#define buffer_ls 2500
char file11[200]="/sdcard/NewLs.txt";
int WriteToLog(char* str)
{
__android_log_print(ANDROID_LOG_INFO,"Tarun1","IN::WriteToLog");
FILE* log;
log = fopen(file11, "a+");
if (log == NULL)
__android_log_print(ANDROID_LOG_INFO,"Tarun1","cannot open file error %s", strerror(errno));
return -1;
fprintf(log, "%s\n", str);
fclose(log);
__android_log_print(ANDROID_LOG_INFO,"Tarun1","OUT::WriteToLog");
return 0;
}
i want rather than printing in file i would like to print it in txt file so i did like this:-
sprintf(buffer_ls,"%-9s %5s %10s %4s %9s %18s %9s %10s %s\n",
"COMMAND",
"PID",
"USER",
"FD",
"TYPE",
"DEVICE",
"SIZE/OFF",
"NODE",
"NAME");
WriteToLog(buffer_ls);
My code fails at sprinf what should i use instead of sprintf?