Skip to content
Sign upLog in
← Back to Community

Overflow problems in C

Profile icon
Arabica

C Language, using the newline trick, worked before, now it does not at all!

Voters
Profile icon
Arabica
Comments
hotnewtop
Profile icon
mwilki7

Which repl are you referring to?
If you are talking about the Interpreter (in C)
https://repl.it/@Arabica/CCP-001

try:

#include <stdio.h> /* For printf() */ #include <string.h> /* For tokenizing and comparing */ #include <stdlib.h> /* For getline() */ int main() { printf("Enter character or somethin idk\n"); // Create input with size 50 char *input = (char*)malloc(sizeof(char) * 50); // Get input (maximum 50 characters) fgets(input, 50, stdin); // Make sure terminator is inside string input[50 - 1] = '\0'; // for loop adjusted to string token for (char *token = strtok(input, " ");token != NULL; token = strtok(NULL, " ")) { // Add C interpeter code thingy here // I'm just printing 'token' printf("%s\n", token); } free(input); printf("program end"); }
Profile icon
Arabica

@mwilki7
This is an old one, I am using fgets() now. I have a learned a lot from then.