Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Segmentation Fault

$
0
0
I'm trying to learn C using the Kernighan and Ritchie C Programmin language book. I've been going through the exercises, but I'm stuck trying to write a program to reverse text. I thing my code is solid, but every time I try to run a file through the program, it comes out blank. any tips? Here's my main method

  
  int main(void){
      int i;
      int len;/*length of array*/
      char line[MAXLINE];/*current line*/
  
      while((len = mygetline(line, MAXLINE)) > 0)    {
          if(mystrlen(line) > 0){
              reverse(line);
              printf("%s", line);
          }
      }
     return 0;
   }
 


I copied the strlen and getline out of the book, because when I tried to use them from stdio.h I got compilation errors. I also got compilation errors using the names strlen and getline so i renamed them. Any help would be great!

Viewing all articles
Browse latest Browse all 51036

Trending Articles