Category : iostream

I am creating a simple login program. #include <iostream> #include <string> using namespace std; void showRegister() { string user; string pw; cout << "Enter your username:"; getline(cin, user); cout << "Enter your password:"; getline(cin, pw); cout << "You have successfully registered!" << endl; writeIntoFile(user, pw); showMenu(); } void showMenu() { int select; do { cout ..

Read more

I have an enum-parameterized class template Id<Target>. I want a stream operator<< specialized for every instantiation of Id, that is, for every value of Target. In the meantime, before implementing the specializations, I tried to write an unspecialized generic version. Which didn’t compile, leading to this question. Why doesn’t the compiler instantiate operator<< with the ..

Read more

I can get this to work by hitting enter twice when it asks for the weight. I don’t know why I need to hit enter twice for though. #include <iostream> using namespace std; int main() { double guestDJ; double guestBart; double guestServ; double guestCat; double guestBand; double elevatorTotal; double xLbs; cout << "Enter the weight ..

Read more

Problem: On executing this windows command line application from windows console, it gets stuck and does not exit/complete. When its stuck it stops consuming CPU and in windows task manager it shows 0% CPU for the process. Getting stuck was not expected and the expectation was to run to completion/exit. Goal: I want to understand ..

Read more

when i use code like char a[10]; char b[10]; char c[10]; char d[10]; cin>>a; //apple cin>>b; //bread cin.get(c,10); //car cin.getline(d,10); // dust and i put "apple bread car dust" In buffer , "applenbreadncarndustn" will stored 2.Then when (buffer data -> array data) 3.a(array) get "apple". and it stop when a meet ‘n’ 4.In buffer[nbreadncarndustn] will ..

Read more