Thread: im new to c programming and need help

  1. #1
    Registered User
    Join Date
    Feb 2022
    Posts
    3

    im new to c programming and need help

    im trying to make a program where the user is asked a username,after he enters it he is greeted, and then he has to type a word to enter(in this case "confirm") and i need help with how to make the program check what the user will input so it knows if its correct or not...here's what ive done so far.

    Code:
    #include <stdlib.h>
    #include<windows.h>
    
    
    int main()
    {
        COORD c;
        c.X = 40;
        c.Y = 15;
    
    
        SetConsoleCursorPosition(
            GetStdHandle(STD_OUTPUT_HANDLE), c);
    
    
        char username[20];
        printf("Enter a username :");
        scanf("%[^\n]s", &username);
        printf("Welcome %s\n", username);
        printf("This is a test\n");
        printf("Type 'confirm' to enter");
    
    
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Sep 2020
    Posts
    150
    Well, you know how to print a prompt and get user input already. Just do it again.
    To compare the input with some value you can use strcmp from string.h

  3. #3
    Registered User
    Join Date
    Feb 2022
    Posts
    3
    @thmm can you explain a bit more i dont understand

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 02-01-2019, 12:27 PM
  2. Replies: 0
    Last Post: 02-01-2019, 12:22 PM
  3. Replies: 4
    Last Post: 12-11-2011, 04:25 PM
  4. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 11:48 PM
  5. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM

Tags for this Thread