Overflow problems in C
Arabica (0)

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

You are viewing a single comment. View All
mwilki7 (152)

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");
}