Hey guys i tried doin this but still dosnt work. What im actually trying to do is read the file line by line then list numbers next to each line then print it to standard out. Sorry for double posting unsure if anyone seen my reply
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int line_no = 1;
int input_char;
FILE *fp;
if(argc !=2) /* check for 2 arguments*/
{
fprintf(stderr, "invalid usage :%s\n", argv[0]);
return 1; /* stop processing if failes */
}
if((fp = fopen(argv[1], "r")) == NULL)
/* opens file for reading and checks if it exists */
{
fprintf(stderr, "invalid usage: %s\n", argv[0]);
return 1; /* stop processing if fails*/
}
printf("dude\n");
while(fscan(stdout, "%d", input_char)!=NULL)
{
fprintf(fp, "%s", input_char);
line_no++;
}
fclose(fp);
return EXIT_SUCCESS;
}