here's the code
Code:
void main
char num[10], cmd[75];
int files;
char *end;
strcpy(cmd, "ls ");
strcat(cmd,scan_data_home);
strcat(cmd," | wc -l");
fp = popen(cmd, "r");
while (fgets(num, sizeof(num)-1, fp) != NULL)
printf("%s\n",num);
files = (int) strtol(num, &end, 10);
printf("%d\n", files);
printf("1 %c\n", num[0]);
printf("2 %c\n", num[1]);
printf("3 %c\n", num[2]);
printf("4 %c\n", num[3]);
printf("5 %c\n", num[4]);
printf("6 %c\n", num[5]);
printf("7 %c\n", num[6]);
printf("8 %c\n", num[7]);
/[code]
here's the output. I tried to duplicate the actual line spacing
[code]
[B] 3739[/B]
0
[B]1 [/B]
[B]2
3
4
5 3
6 7
7 3
8 9[/B]
/[code]
What gives and how to I convert the string to an int.