online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <stdio.h> #include <string.h> int main() { FILE * fp; //open exists file FILE * fn; //open empty file char c[1000]; // buffer char trigger[] = "o'clock"; // the word before which the characters should be added char name [] = "startFile.txt"; // name of source file char secondName[] = "newFile.txt"; // name of output file fp = fopen (name, "r"); // open only for reading if (fp == NULL) { // testing on exists printf ( "Error"); getchar (); return 0; } fn = fopen(secondName, "w"); // open empty file for writing if (fn == NULL) { // testing on create printf ( "Error"); getchar (); return 0; } while (fgets(c, 1000, fp)) { // scanning all string in the source char *p = strstr(c, trigger); if (p) { // ok we found the trigger - now we need to search backwards // to find the end and then the start of the word before while (p>c && p[-1]==' ') p--; // find the end of the word memmove(p+1, p, c+999 - p); // make a space for the ] *p = ']'; while (p>c && p[-1]!=' ') p--; // find the start of the word memmove(p+1, p, c+999 - p); // make a space for the [ *p = '['; } fputs(c, fn); // writing charter from buffer "c" to empty file } fclose(fp); // closing file fclose(fn); return 0; }
Let's go to the graveyard at night - at twelve o'clock!

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