473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

//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");
return EXIT_FAILURE;
}

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

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

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

fclose(g_cov);

fclose(cov_only);
return 0;
}
Jan 18 '11 #1
1 1346
I figured it out. nevermind! had to includ string.h
Jan 18 '11 #2

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

Similar topics

2
by: Alexander Bartzas | last post by:
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...: > g++ packet.cpp radix.cpp route.cpp -o route There is no problem in the compilation of the code but when I try to run...
3
by: Christopher M. Lusardi | last post by:
Hello, THE PROBLEM ----------- If I compile parts of my program with CC, and C, using extern "C" as appropriate it compiles without any errors, but it does a segmentation fault when I run the...
9
by: Maksim Kasimov | last post by:
Hello, my programm sometime gives "Segmentation fault" message (no matter how long the programm had run (1 day or 2 weeks). And there is nothing in log-files that can points the problem. My...
28
by: Robert Gamble | last post by:
I was taking a look at some of the C puzzles at: http://purana.csa.iisc.ernet.in/~gkumar/cquestions.html and have not had any trouble with any of them except for the first one which is reproduced...
3
by: eiselekd | last post by:
Does anyone know about a code snippet that can be used to output a backtrace just like gdb's "backtrace" command does. One that can be called on a segmentation fault. (without resolving symbol...
10
by: eyh5 | last post by:
Hi, My C code (running on Soalris Unix) has some "segmentation fault" that I wish to use purify to do it. I poked around the web, and found some information about adding some lines in a Makefile...
9
by: Gary | last post by:
Hi all! I've taken some time on learning the difference between "pointers to const variables" and "const pointer variables". The question is: in the following code, can we change the contents of...
5
by: arnuld | last post by:
it compiles without any trouble but produces "Segmentation Fault" when i try to run it. since i am at chapter 2 so my knowledge of arrays is limited to chapter 1: -------------------------...
3
by: GB | last post by:
Hi, I used VB2005 (VB.Net Apps) for about a year without problem. And all at a sydden, nothing works now : When starting a project in VB.net (debug mode), I get a strange message : "Error while...
3
by: ShambhuHubli | last post by:
Hi all!! .. I am New member to this group. And also new to C/PYTHON API coding. I am trying to have two way communication i,e i am calling from python to C and then from C to python. I have no...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.