+ 1
Can someone help me with this simple C++ project ?
Trying to create a program that asks the user to input a username and a password (two different accounts to be exact) and save each pair in a string array, but it seems that I have done something wrong. The accounts are not being saved. Ps: I am quiet new to C++ 😜. https://code.sololearn.com/cxHSDex0Ztkg/?ref=app
2 ответов
+ 1
I briefly viewed some of your code. My suggestions would be if your looking for help, put at the top of your program the input requirements, as to help fellow coders quickly understand your program without making them have to read the entire program in order to figure out what needs to be typed in.
I also noticed you are using a string with cin. I dont know exactly what type of input you tried putting in but when using strings I suggest using "getline (cin, Variable);" as this will account for spaces in a word while cin stops once a space is detected.
To really help out fellow coders I would also suggest posting the input and results you already tried as this may help find problems faster. Ive done this plenty of times in my own programs. When I see wrong output I normally know exactly where the problem came from looking at the results.
My Own Notes: This is a little something I found out with strings since ive been coding for a while.
cin.sync(); //discard unread characters in input buffer
//also found out that you need to clear the buffer if you use "cin with a single character input such as ints or chars" and then want to use cin with a string.
I think my above comment may help you. I didnt really run your program to see exactly why your having problems hopefully another coder will help with the problem.
On the upside great use of comments. I like the comments you did add. I know you said your new so as to help give you more ideas on comments. https://code.sololearn.com/cN0J6M2BfXhF/#cpp This is a program I built. To maybe help give a better understanding on commenting on Sololearn because all input is required before the program runs.
+ 1
Ty Ler, thanks for your addvice 😉✌.