Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Baby's first C

Name: Anonymous 2007-07-14 22:06 ID:q/I/CZGz

For my first C project I'm trying to write a commandline text editing program.  Although I'm aware of many problems with this code, I only request advice on one of them.  I would like the for loop I have there to loop around where I have the continues, for example where the continue is after the text input, I want it to loop around so you can select new, save, load or help after inputting text. The way it is right now it just ends the program after one of the commands is executed without looping around at all. I'm using Dev-C++ if that makes a difference.

#include <stdio.h>
#include <string.h>

int main() {
   
    printf("Commandline Text Editor by xxxxxx \n") ;
    printf("Type help to get started \n") ;
   
    int loop = 1;
    for (loop = 1;loop == 1; ) {
        char command[] = "";
        scanf("%s",&command) ;
        if (strcmp(command,"save") == 0) {
                                   //save text to a file
                                   continue;
                                   }
        if (strcmp(command,"new") == 0) {
                                  char textinput[] = "";
                                  printf("Type something...\n") ;
                                  scanf("%s",&textinput) ;
                                  printf("You typed: \n %s \n",textinput) ;
                                  printf("What do you want to do with this text? \n") ;
                                  continue;
                                  }
        if (strcmp(command,"load") == 0) {
                                   //load text file
                                   continue;
                                   }
        if (strcmp(command,"help") == 0) {
                                   printf("Available commands are:\n") ;
                                   printf("new, save, load, help") ;
                                   continue;
                                   }
        else {
             printf("Excuse me, wtf r u doin? Type help for a list of available commands \n") ;
             continue;
             return 0;
             }
    }
    return 0;
}

Name: Anonymous 2007-07-15 6:59 ID:YvN+Kocx

#include <stdlib.h>

int main() {
    system("vim");
    return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List