String Tokenizer
#7
I tried to write a program in C that corresponds to the StringTokenizer in Java, and then call it from QB64, but it does not work.
There are no problems when compiling, but the program crashes when run.

I've tried everything I can think of for over two hours, and according to the manuals, I don't know why the program crashes.
The developers of QB64 know C/C++ - why does the program crash? Where is the mistake?

Code: (Select All)
//Beispiel für StringTokenizer aus Java in C
//Schildt, S.338 - 26. Mai 2023

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char *text;
    
    text = strtok("They came never back!", " ");
    printf(text);
    printf("\n\n");
    do
    {
        text = strtok('\0', " ");
        if (text)
        {
            printf("\n%s", text);
        }        
    }while(text);
    
    return(0);
}

[Image: Token-Problem2023-05-26.jpg]
Reply


Messages In This Thread
String Tokenizer - by a740g - 05-25-2023, 03:33 PM
RE: String Tokenizer - by RhoSigma - 05-25-2023, 09:33 PM
RE: String Tokenizer - by a740g - 05-25-2023, 10:45 PM
RE: String Tokenizer - by Kernelpanic - 05-25-2023, 11:04 PM
RE: String Tokenizer - by a740g - 05-26-2023, 12:21 AM
RE: String Tokenizer - by Ultraman - 05-26-2023, 03:56 PM
RE: String Tokenizer - by Kernelpanic - 05-26-2023, 08:44 PM
RE: String Tokenizer - by Kernelpanic - 05-30-2023, 09:15 PM
RE: String Tokenizer - by Ultraman - 06-29-2023, 11:42 AM



Users browsing this thread: 7 Guest(s)