Thread: plz help me anybody regarding this program

  1. #1
    Registered User
    Join Date
    Apr 2010

    Unhappy plz help me anybody regarding this program

    void main()
    char a[]="soft",b[4];
    int i,n;
    if (n==0)
    cout<<"Invalid Password";
    when i m running this program i always get invalid password...........
    Last edited by Salem; 04-30-2010 at 09:54 AM. Reason: Added [code][/code] tags - learn to use them yourself (as well as how to indent code)

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    First, please use [code][/code] tags

    You cannot compare characters arrays that are not null-terminated using strcmp. 'b' needs to be long enough to hold 5 characters to include the null character. You should ideally use '\0' for the nul-terminator as well, rather than NULL, for clarity.
    Also, main must return int, never void.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  2. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  3. plz help me with simple string comparison.
    By MegaManZZ in forum C++ Programming
    Replies: 11
    Last Post: 02-18-2008, 01:11 PM
  4. Anyone plz help me
    By Rose_Flowers in forum A Brief History of
    Replies: 1
    Last Post: 09-17-2003, 12:01 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 08:44 AM

Tags for this Thread