online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <stdbool.h> #define MAX_LINES 1000 #define MAX_TOKENS 100 int main() { char filename[100]; FILE *fp; printf("Enter the filename: "); scanf("%s", filename); fp = fopen(filename, "r"); if (fp == NULL) { printf("Error opening file.\n"); return 1; } printf("File opened successfully.\n"); // tokenize each parameter in the file and store in 2D array char lines[MAX_LINES][MAX_TOKENS]; char line[MAX_TOKENS]; char *token; int i = 0, j; while (fgets(line, MAX_TOKENS, fp) != NULL && i < MAX_LINES) { j = 0; token = strtok(line, " \t\n"); while (token != NULL && j < MAX_TOKENS) { strncpy(lines[i][j], token, MAX_TOKENS); j++; token = strtok(NULL, " \t\n"); } i++; } // print the 2D array for (int k = 0; k < i; k++) { for (int l = 0; l < j; l++) { printf("%s ", lines[k][l]); } printf("\n"); } fclose(fp); return 0; }
1 0 0 0 0 1 0 0 0 1 0 0 0 1 3024.dat 1 0 0 8 0 1 0 0 0 1 0 0 0 1 3024.dat 1 0 0 16 0 1 0 0 0 1 0 0 0 1 3024.dat 1 0 0 48 0 1 0 0 0 1 0 0 0 1 3004.dat

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue