Results 1 to 5 of 5

Thread: Why is it ignoring part of my code?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Code:
    char Name[101];
    	int Phone;
    	char Address[101];
    	cout<<"Enter the name of a person: "<<endl<<">";
    	cin.getline(Name,101,'\n');
    	cout<<"Enter "<<Name<<"'s phone number:  "<<endl<<">";
    	cin>>Phone;
    	cout<<"Enter "<<Name<<"'s address:  "<<endl<<">";
    	cin.getline(Address,101,'\n');
    
    	cout<<"========================================"<<endl;
    	cout<<"Name: "<<Name<<endl<<"Phone: "<<Phone<<endl<<"Address: "<<Address<<endl;
    This is my code, but when it runs, it doesn't execute the bold part. Why is this? Is it just my computer?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    It works now but only because I changed the Phone number to a string. Can you only call these once? Do I have to call something to end a getline?

  3. #3
    Addicted Member
    Join Date
    Jan 1999
    Posts
    204
    does the address have a space in it sometime a compiler mite think the space is the send of it . but i dont know
    WHat would we do with out Microsoft.
    A lot more.

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I tend to use stdio.h's Gets to get a whole line.

    Code:
    void Main()
    {
    char sIn[120];
         gets(sIn); //get the whole line
         return;
    }
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Its not because of a space (I've tried it with my name) and the ending character is '\n'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width