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