strtok Questions

3

Solved

This is my code #include<stdio.h> #include<stdlib.h> void main() { FILE *fp; char * word; char line[255]; fp=fopen("input.txt","r"); while(fgets(line,255,fp)){ word=strtok(line,...
Vicky asked 7/1, 2017 at 15:42

3

Solved

I'm having problems in figuring out where and why I'm receiving a segmentation fault. I'm writing a C code that prompts the user to input a regular expression and compile it and then enter a stri...
Anthemion asked 22/4, 2016 at 22:24

6

Solved

I am trying to tokenize a string but I need to know exactly when no data is seen between two tokens. e.g when tokenizing the following string "a,b,c,,,d,e" I need to know about the two empty slots ...
Levinson asked 2/1, 2012 at 22:12

8

Solved

I was wondering how you could take 1 string, split it into 2 with a delimiter, such as space, and assign the 2 parts to 2 separate strings. I've tried using strtok() but to no avail.
Highpressure asked 26/3, 2010 at 13:17

1

New in C and pretty confused about how to deal with several strings at the same time using strtok, for a simply example, I want to use strtok to extract the number and compare then. #include <s...
Impair asked 1/11, 2015 at 18:42

2

Solved

what I want to do is given an input string, which I will not know it's size or the number of tokens, be able to print it's last token. e.x.: char* s = "some/very/big/string"; char* token; cons...
Kan asked 28/9, 2015 at 12:27

3

Solved

I am serializing some C structure to string and than deserializing it with strtok(). But, unfortunately, strtok() don't detect empty fields (eg 1:2::4). Is there any alternative function?
Ogdon asked 4/3, 2010 at 8:20

5

Solved

I am trying to separate a string into multiple strings, to make a customized terminal. So far I have been separating control signals using strtok, however I do not understand how to separate specif...
Bren asked 10/5, 2015 at 7:31

2

Solved

This is the explanation of strtok(). #include <string.h> char* strtok( char* s1, const char* s2 );* The first call to strtok() returns a pointer to the first token in the string point...
Wein asked 14/4, 2015 at 22:39

3

Solved

strtok wont work correctly when using char *str as the first parameter (not the delimiters string). Does it have something to do with the area that allocates strings in that notation? (which as fa...
Clite asked 27/3, 2010 at 15:31

1

Is strtok hopelessly broken? On many StackOverflow questions about text-parsing in C, someone will suggest using strtok, and one common reply is that strtok should never be used, that it is hopele...
Fugger asked 18/2, 2015 at 16:7

4

Solved

I have the following code to tokenize a string containing lines separated by \n and each line has integers separated by a \t: void string_to_int_array(char file_contents[BUFFER_SIZE << 5], i...
Gaunt asked 30/5, 2014 at 18:27

4

Solved

What's the difference between strtok and strtok_r in C and when are we supposed to use which?
Linguini asked 5/3, 2014 at 22:15

7

Solved

I need to use strtok to read in a first and last name and seperate it. How can I store the names where I can use them idependently in two seperate char arrays? #include <stdio.h> #include &l...
Olly asked 12/11, 2011 at 18:57

4

I found this sample program which explains the strtok function: #include <stdio.h> #include <string.h> int main () { char str[] ="- This, a sample string."; char * pch; print...
Berty asked 13/1, 2014 at 17:11

3

for some reason i get an exception at the first use of strtok() what i am trying to accomplish is a function that simply checks if a substring repeats itself inside a string. but so far i ha...
Lava asked 28/12, 2013 at 9:42

2

I'm writing a C program to study the usage of function strtok(). Here is my code: #include <stdio.h> #include <string.h> main() { char abc[100] = "ls &"; char *tok; tok = strt...
Reprobate asked 21/9, 2013 at 0:49

2

Need help in strtok function #include<stdio.h> #include<string.h> int main() { char string[100], *ptr = NULL; memset(string, 0, 100); strcpy(string, "abc#efg#xyz"); ptr = strtok...
Whinny asked 16/8, 2013 at 14:7

1

Solved

I am trying to use strtok(). Following is the piece of code that I wrote. It does not work but prints ", '" infinitely. #include<stdio.h> #include<stdlib.h> #include<string.h&...
Loaves asked 27/7, 2013 at 10:1

1

Solved

I am new to C and I am trying to split a date/time string into separate variables. However, when I step through the code in gdb line by line, it works, however, when I let it run through normally w...
Pentachlorophenol asked 9/7, 2013 at 15:3

4

Solved

I have the following code: #include <stdio.h> #include <string.h> int main (void) { char str[] = "John|Doe|Melbourne|6270|AU"; char fname[32], lname[32], city[32], zip[32], country...
Jarrell asked 14/6, 2013 at 9:8

5

Solved

In the following program, strtok() works as expected in the major part but I just can't comprehend the reason behind one finding. I have read about strtok() that: To determine the beginning and t...
Octet asked 15/5, 2013 at 17:7

2

Solved

When i'm not calling the same function in my code everything works well but when the function returns from a recursion suddenly the variable pch is NULL: void someFunction() { char * pch; char...
Draggle asked 14/11, 2012 at 6:16

4

Solved

strtok_r is the reentrant variant of strtok. It is POSIX-conformant. However, it is missing from MinGW, and I'm trying to compile a program that is using it. Is there any way I could add a standar...
Naphtha asked 19/10, 2012 at 13:12

2

Solved

I am having trouble with using execvp(). execvp() expects type char * const* as second parameter. I want to parse arguments passed to application (in argv) and make an array of that type. For examp...
Otherdirected asked 18/10, 2012 at 18:13

© 2022 - 2024 — McMap. All rights reserved.