2022-12-30 16:29:57 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
void *pBuf = malloc(256);
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
|
2023-01-21 21:53:55 +00:00
|
|
|
|
for (int i=0; i<=argc; i++) printf("argv[%D]=%s\r\n", i, argv[i]);
|
|
|
|
|
getchar();
|
2022-12-30 16:29:57 +00:00
|
|
|
|
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
|