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
2 answers

C-string alternatives to strtok_r() and strsep() that don't modify the original string pointer?

I was taking a look at the 2 C-string functions, strtok_r() and strsep(), and noticed both functions modify the location of the original string passed in. Are there any other C-string functions that don't modify the original string passed in? In my…
Stephen Wong
  • 177
  • 1
  • 8
0
votes
1 answer

Segmention Fault on the while in reviews.csv

When i try run with the reviews.csv file the code gives segmention fault don't know why!! Can someone HELP me with that... In guião1v2.h only are the structs made for this. In the code i add some comments for being much easier understand what i'm…
0
votes
1 answer

Using loop to and atof to make more then ten thousands str to be double, but only a few work in C program

Below code is a C code, t is a string from a txt document, there are 10000+ strings here, like what I print in the code printf("%s\n", t);, I can see many str. However, when I use atof to make t become int, there is only 72 str become double, does…
Lee Alex
  • 171
  • 2
  • 3
  • 13
0
votes
1 answer

Trying to print the last element in string of numbers

I have this code in C, where I will be inputting a string of numbers separated by spaces, and splitting it with strsep. If I input a string like "1 2", and set strcmp to look for a number before the last element, the code works, but if I set strcmp…
0
votes
1 answer

Is there a built in function to get the back half of a strsep()?

In short, currently the code below outputs: The substring is AES. Unfortunately, I'm looking to get the result The substring is 100. This is due to the fact that strsep() keeps only the first portion of the split, and not the second. Is there a way…
Xenorosth
  • 97
  • 1
  • 9
0
votes
0 answers

How to correctly use strsep() to parse an array?

I'm trying to implement a function that takes a string to parse and delimiter string as inputs, then returns a char array containing these parsed elements including empty chars if two delimiters are adjacent. Below is my current code: String*…
0
votes
0 answers

Segmentation Fault while trying to parse an excel style .CSV file [C programming]

I've been stuck on this project for the better part of the week and while I have been grinding through syntax errors. The gist of the project is to read through the headers and stopping at a certain column and finding certain characteristics like…
0
votes
0 answers

How to pass the string value pointed by a token to an array in C?

I'm trying to put the elements from a .csv file to a 2 dimensional array. Here is the code I've wrote so far. #include #include #define MAX_SIZE 200 char* data[33][13]={0}; int i = 0; int j = 0; void passDataToArray() { …
Emre Utku Solak
  • 336
  • 2
  • 10
0
votes
1 answer

Strsep, Parsing CSV Input further

Using strsep to split a CSV with a bunch of usless junk in it ("," Delim). One of the entries has quotes on either side (ie Florida,"Bob",1999) and I'd like to pull those out before I save them in my array. How do I remove the quotes from the name? …
SsedOut
  • 41
  • 3
0
votes
0 answers

best way to strsep(null,",") for csv for special cases

I'm using strsep to parse a csv example input from stdin Color,Andrew Adamson,284,150,80,82,Kiran Shah,1000,291709845,Adventure|Family|Fantasy,Jim Broadbent,"The Chronicles of Narnia: The Lion, the Witch and the Wardrobe ",286506,1317,Shane…
mKalita
  • 49
  • 8
0
votes
1 answer

Parsing CSV file into Structs using C

I am trying to parse a CSV File and put values into a struct, but when I exit my loops I only get returned the value of the file. I can't use strtok because some of the values in the csv file are empty and they get skipped over. My solution was…
andrewF
  • 54
  • 8
0
votes
0 answers

How is strsep working here? Why?

I am trying to learn about writing servers in C and have come across something that is really confusing me. I have been trying to understand some code (not mine). I understand most of it...except this one crucial element in this parse…
gloopit
  • 437
  • 2
  • 9
0
votes
0 answers

c strsep and return value: warning while compiling

I get this warning while compiling my c-code (in c89/90), and I´m lost how to fix that. can anybody help? edge_target is a pointer, and strsep returns a pointer, it should be all ok, or am I missing something? warning: assignment makes pointer from…
jacksbox
  • 911
  • 1
  • 11
  • 24
0
votes
1 answer

C - strsep() function with int error, return value is char*

I used strsep() in C code, but I got this error. void get_token() { char *token; char *stringp; int n = 1; stringp = buf; while( stringp != NULL ) { token = strsep(&stringp, "\t\n"); …
Jung
  • 81
  • 10
0
votes
1 answer

C Segment Fault on char** Array

I am unsure why I am receiving a segmentation fault when my program hits the first if statement. This is a method in a simpleShell program that's sole purpose is parsing stdin input stored in cmd and parse by whitespace into separate arguments in…
Sean
  • 1,283
  • 9
  • 27
  • 43