So I wrote this code using PICO through my terminal...
#include<stdio.h>
#include<stdlib.h>
int main()
{
int lineCount =0;
int c;
while((c=getchar()) != EOF)
{
if (c=='\n'){
++lineCount;
printf("%d\t%c",lineCount,c);
}
}
exit(0);
}
/*print out the "c" which is the words you want to print and then print out
the line number before every new line, think of %d as placeholder */
So now I want to use this code and apply it to a "hello world" script in C. In my terminal, I have both line_number
and hello world files compiled and in 1 folder. I go to the folder and type out line_number < hello.c
and it gives me an error...
-bash: line_number: command not found
my goal is to apply my line number code to my hello world script so that each line of my hello world code has a number in the beginning. My line_number code might also be faulty but if I can get help on getting the command to execute I can resolve the bugs and formatting through trial and error.