Questions tagged [strsep]

Questions involving the use of the BSD strsep() function.

strsep() is a function originating in BSD Unix which operates in a similar manner to the standard C strtok() function. The main difference is that this function may return empty tokens, whereas strtok() returns only non-empty tokens.

56 questions
0
votes
1 answer

C - strsep splitting strings

I created a parseCmd method for my simpleShell program in C, and store each argument before a delimiter whitespace to be stored in my args[] array. However, I am trying to add arguments with their respective parameters into a linked list, but I am…
Sean
  • 1,283
  • 9
  • 27
  • 43
0
votes
0 answers

I don't understand this segfault in strsep()

I'll get right to the point. I have a function that reads a command string from a socket, and then breaks that string into a struct: typedef struct{ char* command; char* option; } Command; If there is no option in the command string,…
shermanzach
  • 591
  • 1
  • 6
  • 14
0
votes
1 answer

Self-made strsep() in windows

I am trying to port some code I have in linux to Windows but I am having problems at porting the strsep() function. I have looked up in the forums and found this: https://stackoverflow.com/a/8514474/2833912 but it is not parsing correctly the field…
Jesús Ros
  • 480
  • 2
  • 6
  • 19
0
votes
0 answers

Problems with Parsing

How do I parse an html/txt file using only strtok and/or strsep? I'm trying that saves the text parts of a wikipedia article to a .txt file. The first part of my code allows me to download the article in html form. The thing I should do next is to…
0
votes
2 answers

Use strsep() with separator in certain order?

I'm trying to parse a text string (char *) using strsep(), the problem is that the separators must be used by order ex.: the first token by ',' the 2nd by ':'... sep = " ,:-,.!."; tofree = string; while (token = strsep(&string, " ,:-,.!.")) …
user776343
0
votes
2 answers

use of strsep in C while parsing argv Variable doesen't work

I have a problem in C while parsing the argv Variable. This is the task: I got some Parameters form the Command line into my C programm. One of them looks like "-r=20-5". There I have to find the "r". this works with: if (argv[i][0] != 0 &&…
waXve
  • 792
  • 2
  • 9
  • 30
-1
votes
2 answers

Segmentation fault using strsep

I'm trying to use strsep to remove extra characters in an CSV file. The problem is that when I run it, it gives me Segmentation Fault and I can't figure out why. Here's the code: #include #include #include #include…
TelmoFP1
  • 1
  • 1
-1
votes
3 answers

Calling printf() after strsep() inside for loop causes a segfault

I'm writing my own UNIX shell in C and I'm trying to add support for passing multi-word arguments within quotation marks (i.e. echo "This is a test"). In my current function (parseCommandWords) that you can see below, I'm successfully separating the…
Stelios Papamichail
  • 955
  • 2
  • 19
  • 57
-1
votes
1 answer

How to split line I read from file with delimiters and store them in each int variable in C

Hi I'm completely new to C and used to code in python so this has been bothering me for a while but I couldn't find an answer that I've been looking for so I decided to ask here. I am reading a file called "input_date.txt" and will have to split it…
yerim2
  • 83
  • 10
-1
votes
1 answer

Need help using the strsep function in c

int main(int argc, char *argv[]) { char *line, buffer[1024]; char *token, *setValue, *pointer; FILE *fp = fopen("file", "r"); if(fp == NULL) { printf("File was unable to be opened.\n"); } …
ancd3ea4
  • 195
  • 1
  • 1
  • 14
-3
votes
1 answer

How strsep works in C?

I'm creating a program that when launched takes in input a command and some arguments with scanf and calls execvp using those arguments. I'm doing this with strsep. I store the string in an array (char*),then I want to split it and store tokens in a…
feded
  • 109
  • 2
  • 13
1 2 3
4