strtok Questions

4

Solved

Possible Duplicate: How do I tokenize a string in C++? Hello I was wondering how I would tokenize a std string with strtok string line = "hello, world, bye"; char * pch = strtok(lin...
Cida asked 27/9, 2012 at 17:49

3

Solved

Let's say I'm using strtok() like this.. char *token = strtok(input, ";-/"); Is there a way to figure out which token actually gets used? For instance, if the inputs was something like: Hello t...
Monteiro asked 17/9, 2012 at 13:28

3

Solved

I think I need a reverse version of strtok, like: char* p = rstrtok(str, delimeters); For example, sequentially get the position of '-', '_' and '+' in the string "hello+stack_over-flow" using a...
Tuberculosis asked 18/6, 2012 at 6:35

3

Solved

I have a const char* variable which may have a value like "OpenStack:OpenStack1". I want to tokenize this const char* using strtok where the delimiter(which is of a const char* type) is ":" . But t...
Shelton asked 23/4, 2012 at 13:40

1

Solved

Say I have three c-style strings, char buf_1[1024], char buf_2[1024], and char buf_3[1024]. I want to tokenize them, and do things with the first token from all three, then do the same with the sec...
Boarder asked 27/2, 2012 at 21:51

3

Solved

Ok, so I understand that strtok modifies its input argument, but in this case, it's collapsing down the input string into only the first token. Why is this happening, and what can I do to fix it? (...
Mozzetta asked 23/2, 2012 at 2:52

2

Solved

The following code works differently on 64 bit and on 32 bit which is causing me trouble to port my code. char * tmp = "How are you?"; printf("size of char * = %ld and size of strtok return val =...
Peter asked 21/2, 2012 at 0:45

2

Solved

I want to break down a sentence and store each string in an array. Here is my code: #include <stdio.h> #include <string.h> int main(void) { int i = 0; char* strArray[40]; char* wr...
Masjid asked 8/11, 2011 at 19:43

3

Solved

when I use strtok to tokenize a c++ string, it happens a confusing problem, see the simple code below: void a(string s){ strtok((char*)s.c_str(), " "); } int main(){ string s; s = "world hello"...
Nissie asked 1/10, 2011 at 3:31

4

Solved

What feature(s) of strtok is unsafe (in terms of buffer overflow) that I need to watch out for? What's a little weird to me is that strtok_s (which is "safe") in Visual C++ has an extra "context" ...
Flowery asked 14/5, 2011 at 2:18

2

Solved

I have two helper functions to break up strings in the format of decimal prices ie. "23.00", "2.30" Consider this: char price[4] = "2.20"; unsigned getDollars(char *price) { return atoi(strto...
Unquestionable asked 8/5, 2011 at 3:24

2

Solved

I have a string like this: a;b;c;d;e f;g;h;i;j 1;2;3;4;5 and i want to parse it element by element. I used nested strtok function but it just splits first line and makes null the token poi...
Mikimikihisa asked 14/1, 2011 at 17:17

3

Solved

I'm using strtok() in c to parse a csv string. First I tokenize it to just find out how many tokens there are so I can allocate a string of the correct size. Then I go through using the same variab...
Blessed asked 28/12, 2010 at 6:8

3

Solved

I think it's the very first strtok call that's failing. It's been a while since I've written C and I'm at a loss. Thanks very much. #include <stdio.h> #include <string.h> int main(int...
Godber asked 18/12, 2010 at 22:39

3

Solved

I have a text file with three fields separated by comma. Example of the content of my text file: 12345, true programming newbie, BS ME To load the file into the program, i used the below code.... ...
Shumway asked 2/12, 2010 at 13:44

6

Solved

Possible Duplicate: strtok wont accept: char *str When using the strtok function, using a char * instead of a char [] results in a segmentation fault. This runs properly: char strin...
Armet asked 3/11, 2010 at 18:39

4

Solved

I wrote a simple url parser using strtok(). here's the code #include <stdio.h> #include <stdlib.h> typedef struct { char *protocol; char *host; int port; char *path; } aUrl; voi...
Tarrant asked 29/9, 2009 at 22:52

2

Solved

I have been spending some time in debugging a programme which gives segmentation fault. The bug is quite indeterministic and intermittent, which is annoying. I narrowed it down to the calling of st...
Swadeshi asked 27/10, 2010 at 8:4

3

Solved

I am trying to use strtok() in nested loops but this is not giving me desired results, possibly because they are using the same memory location. My code is of the form:- char *token1 = strtok(Str1,...
Ordzhonikidze asked 2/10, 2009 at 13:55

5

Solved

OK. For example I have this line in my txt file: 1|1,12;7,19;6,4;8,19;2,2 As you can see, it has 2 parts, separated by |. I have no problems getting both parts, and separating second part 1,12;7,1...
Weekly asked 10/4, 2010 at 9:39

1

Solved

I'm trying to count the number of words in a file with strtok(). /* * code.c * * WHAT * Use strtok() to count the number of words in a file. */ #include <stdio.h> #include <stdlib.h&...
Photopia asked 15/2, 2010 at 11:0

6

Solved

Can anyone explain why I am getting segmentation fault in the following example? #include <stdio.h> #include <string.h> int main(void) { char *hello = "Hello World, Let me live."; c...
Daveta asked 9/2, 2010 at 6:24

5

Solved

What would be an efficient way of converting a delimited string into an array of strings in C (not C++)? For example, I might have: char *input = "valgrind --leak-check=yes --track-origins=yes ./a...
Clash asked 31/1, 2010 at 2:29

5

Solved

char *strtok(char *s1, const char *s2) repeated calls to this function break string s1 into "tokens"--that is the string is broken into substrings, each terminating with a '\0', where the '...
Reformation asked 7/11, 2008 at 17:32

© 2022 - 2024 — McMap. All rights reserved.