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...
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...
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...
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...
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...
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? (...
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...
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"...
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" ...
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...
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...
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...
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.... ...
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...
4
Solved
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,...
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...
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&...
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...
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 '...
© 2022 - 2024 — McMap. All rights reserved.