in a currecnt program i am working on, i have places where the user would enter there first and last name. when i run the program, it completly passes bye that part and fills in all the other fields aswell. and then later when the name is ouputed it has no value.
here is the part of the code:
as you can see i use the cin.get and cin.ignore since they are character strings and i am using a struct which is why there is a V. and then variable nameCode:cout << "\n\nFirst Name: "; cin.get(V.FirstName,20); cin.ignore(80,'\n'); V.FirstName[0]=toupper(V.FirstName[0]); cout << "\nLast Name: "; cin.get(V.LastName,30); cin.ignore(80,'\n'); V.LastName[0]=toupper(V.LastName[0]); strcpy(V.FullName, V.FirstName); strcat(V.FullName, " "); strcat(V.FullName, V.LastName);
also this is the first program i passed structs from one function to another
here is the struct:
and here's main if you need it:Code:struct Variables { char FirstName[20], LastName[30], FullName[50], Password[10], PW[10], User, Print, acnumber[8]; int Attempts; float Balance, Deposits, Withdrawls, NewBalance; };
can anyone explain why these things are being passed bye wen running the program? thanks for your help in advance.Code:int main () { Variables V; V.Attempts=0; V.Balance=0; V.Deposits=0; V.Withdrawls=0; V.NewBalance=0; Intro(V); AccountNumber(V); createorisregistered(V); printcorrect(V); getch(); return 0; }



LinkBack URL
About LinkBacks


