By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

Segmentation Fault in C when trying to parse on "\t":

P: 2
//I apprecaite any help~!

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])

FILE *g_cov, *cov_only;
char line[50];

if(argc !=2 ){//argc already has value of one. therefore, must be 2 for one argument.
fprintf(stderr, "No arguments passed to grab_cov.c");

g_cov= fopen(argv[1], "r");

cov_only=fopen("cov.only.out", "w");

printf("can't open argv[1] for reading");
return 1;
while(fgets(line, sizeof line, g_cov)!=NULL)
char* token=strtok(line, "\t");
printf("[%s]\n", token);
token=strtok(NULL, "\t");


return 0;
Jan 18 '11 #1
Share this Question
Share on Google+
1 Reply

P: 2
I figured it out. nevermind! had to includ string.h
Jan 18 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.