Thread: basic troubleshoot true and false

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    62

    basic troubleshoot true and false

    each time i input a letter for example, rtyy the output is long and i dont want it to read long it should input stupied. but when i input r it will give me long. So i need help on this

    main()
    { char a;
    system("cls");

    scanf ("%c",&a);

    if (a == 'r')
    printf("\n long'");

    else
    if (a == 'b')
    printf("\n short");


    else
    if (a!= 'r')
    printf("\nstupied");

    getch();

    }

  2. #2
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Use some code tags around your code, rtyy is not a letter it is 4, when you give it r it will print "\nlong", and to print "\nstupied" just swap the if(a=='r') to if(a!='r') and vice versa.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BIG problem. How do I find a bug in so much code?
    By Yarin in forum C++ Programming
    Replies: 44
    Last Post: 01-31-2008, 12:39 PM
  2. C++ FTP class won't work
    By lord mazdak in forum C++ Programming
    Replies: 8
    Last Post: 12-18-2005, 07:57 AM
  3. Reducing Code size from ridiculous length
    By DanFraser in forum C# Programming
    Replies: 10
    Last Post: 01-18-2005, 05:50 PM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM