Thread: Making a word verification in C

  1. #1
    Registered User
    Join Date
    Sep 2018

    Lightbulb Making a word verification in C

    Hi, I have to make a code where i talk about computer hardware. Now I want to know how to make that when you type further, you go further. else you get the message, sorry, i don't know what you mean.
    Here is a bit of the code I already have:

    char nextstap[7]={'v','e','r','d','e','r','\0'};
        puts("Hallo, dit is een programma dat gaat over randapparatuur.\n"); //intro
        puts("We gaan het over verschillende onderdelen hebben maar eerst is het handiger\n");
        puts("om het te hebben over wat randapparatuur nou daadwerkelijk is!\n");
        puts("Type 'verder' om door te gaan: ");
        if (scanf("nextstap"%c))
                puts("Dit commando ken ik niet!");
                puts("Goed, we gaan verder met de geschiedenis van randapparatuur");
        return 0;

  2. #2
    Registered User
    Join Date
    Sep 2018
    sorry, verder means further

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    The best way forward is to do something like
    char buff[BUFSIZ];
    if ( fgets(buff,sizeof(buff),stdin) != NULL ) {
        if ( strlen(buff) == strlen(nextstap)+1 && strncmp(buff,nextstap,strlen(nextstap) == 0 ) {
            // the string is the right length, and matches what we want.
        } else {
            // user typed in either
            // verder + more letters
            // something other than verder
    } else {
        // fgets detected eof or error
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 28
    Last Post: 10-23-2011, 07:17 PM
  2. Need VS2008 Verification
    By rags_to_riches in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2008, 04:51 AM
  3. Replies: 2
    Last Post: 01-21-2008, 02:07 AM
  4. Password verification
    By WannaB_Geek in forum C++ Programming
    Replies: 1
    Last Post: 08-24-2004, 12:58 PM
  5. Code Verification !!
    By mehuldoshi in forum C Programming
    Replies: 6
    Last Post: 07-02-2002, 10:14 AM

Tags for this Thread