Contribute
Register

C++ Programming question.

Status
Not open for further replies.
Joined
Mar 3, 2010
Messages
72
Motherboard
GA-P55M-UD2
CPU
Intl Core i5
Graphics
EVGA GTX 750TI 2GB FTW
Mac
  1. MacBook Air
Classic Mac
  1. 0
Mobile Phone
  1. iOS
Ok, this is driving me nuts, i don't see what i'm doing wrong..

I uploaded code to a pastebin for easy access and that way u guys can see the syntax highlighting. :)

http://pastebin.com/9yQisKvA

:banghead:
 
What's the type of holdUsername ?
Are you sure you want its sizeof and not its strlen ?
 
I had my son a Software Engineering major look at the code and the issue is in the if statement on line 29.

He asks what are you trying to check? Is it if the entered name is less than 2 characters?

If so, then he suggested that you use "holdUsername.size()" or "holdUsername.length()".
 
:) I will give it a shot, thanks guys!
 
intrus22 said:
:) I will give it a shot, thanks guys!

It is definitely the 'sizeof()' function; you want it to be 'strlen()', because you are determining the length of the string (seen as a zero-terminated [NUL] sequence of printable bytes) held in the variable and *not* the size of the variable. sizeof() would probably in this case (since I don't know what type holdUsername is) return the size of a pointer, or 4 in 32-bit systems.

If the variable is a string class instance, you might be able to check it's length through a length checking method inside the class. I hate C++; praise plain ol' C forever!

-egonline
 
Status
Not open for further replies.
Back
Top