A2osX/ROOT/ctest/testloop.c.txt

33 lines
688 B
Plaintext
Raw Normal View History

NEW
AUTO 3,1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void *pBuf = malloc(256);
int main(int argc, char *argv[]) {
for (int i=0; i<=argc; i++) printf("argv[%D]=%s\r\n", i, argv[i]);
getchar();
strcpy(pBuf, argv[0]);
strcat(pBuf, ".c");
printf("Filename=%s\r\n", pBuf);
short int hFile = fopen(pBuf, O_RDONLY, 0, 0);
printf("hFile=%d\r\n", hFile);
int linecnt=0;
while (NULL == fgets(hFile, pBuf, 255)) {
linecnt++;
printf("%5D:%s\r\n", linecnt, pBuf);
}
fclose(hFile);
getchar();
free(pBuf);
puts("All done.");
}
MAN
TEXT root/ctest/testloop.c