TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: DARRELL HNIZDOR
date: 1997-10-07 13:49:00
subject: cin.getline

I have a problem with cin.getline using Borland C++
Below is a copy of a function which works fine until referenced within a 
WHILE loop, then the cin.getline doesn't execute, however, if I put two 
identical lines it does execute.  The problem also occurs with other string 
input functions.
  int addrec()
  {
  studentData student;
  int cnt = 0;
   while (cnt == 0)
       {
      cout << "Add record" << endl;
  cout << "Name: " ;
       cin.getline(student.name,30);
          cout << student.name << endl;
          char *s1 = student.name;       //looks for cr
          char *s2 = "";
       	int st;
       	st = strcmp(s1,s2);
   	if (st == 0)
  	cnt = 1;
     	}
  return 0;
  }
--- Maximus 3.01
---------------
* Origin: Friendship Corner Albany, Tx 1-915-762-2745 (1:392/15)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.