Ive been following the examples and tutorials in K&R the c programming language yet i have no idea how to use files, for example The code below shows an attempt at counting the amount of tabs in a text file however, once compiled $./program text.txt doesn't do anything. Any help is appreciated.
Code:#include <stdio.h> int main (int argc, char *argv[]) { int c, nt; nt = 0; while ((c = getchar()) !=EOF) if (c == '\t') nt++; printf("%d tabs", nt); return 0; }



LinkBack URL
About LinkBacks


