Thread: testing for blank line

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    52

    testing for blank line

    How do I test for a blank student name
    ie if ((pa+i)->fullname==blank line)
    break;

    Code:
    int getinfo(student pa[], int n)
    {
    	
    	int i;
    	for (i=0;i<n;i++)
    	{
    		cout << "Enter the name of student "<< i+1 <<":";
    		cin.getline((pa+i)->fullname,SLEN);
    		if ((pa+i)->fullname=='\0')
    			break;
    		cout << "Enter student "<<i+1<< " hobby:";
    		cin.getline((pa+i)->hobby,SLEN);
    		cout << "Enter student "<< i+1<< " ooplevel:";
    		cin >>(pa+i)->ooplevel;
    		cin.get();
    	}
    	return i;
    }

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Well Why dont you just get the length of the name and if its 0 then it was a blank line.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    52

    test for blank name

    is there a function to determine the length?
    can't find one in this book

  4. #4
    Registered User heljy's Avatar
    Join Date
    Mar 2002
    Posts
    36
    strlen() does that.

    I think its included in <string.h>
    If only life is as easy as C...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do encryption in C
    By sankarv in forum C Programming
    Replies: 33
    Last Post: 12-28-2010, 11:01 AM
  2. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  3. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 05:44 PM
  4. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM