Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

Overflow problems in C

Arabica
Arabica

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

3 years ago

Voters

Comments

TopNew
1
mwilki7
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"); }
3 years ago
1
Arabica
Arabica

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

3 years ago
Load more