0
How i can use bool function and strcmp in structures
I want to write program which will check the name. Itry this in following code: https://code.sololearn.com/cA5a5A6a17a1/?ref=app
9 Respostas
+ 6
You are defining isTrue() twice instead of having a declaration and a definition, which results in the second one not having a proper declaration. If the second one is the method you want, replace the definition inside the structure by the corresponding declaration:
bool isTrue();
You also forgot to include the <cstring> header file for strcmp(), while <iomanip> and <cmath> seem to be redundant.
+ 3
1) Include the <string.h> or <cstring> library (they are the same) for "strcmp" function.
2) Remove the "<char> ime" parameter from your method and it will automatically use class' attribute. And the definition of a method/function "Human::imo" outside the "Human" definition is unnecessary: you have already defined it; it is necessary only if you declared and not defined it.
+ 2
Am I the only one not getting the input dialog to come up with `cin.getline`? the code isn't asking for input even after the fix.
+ 2
get
You edited your last post. The two sentences you talked about wasn't there when I read it.
And please, don't give me stuffs that are not in the OP's code cause that is another story.
+ 2
get
My actual intention was to get the OP to learn and use C++ string in C++ code unless char array was really necessary.
+ 1
Ipang, "ostream::std::cin.getline" is used to receive string (raw) input with spaces. It is SoloLearn's issue that it does not ask for input in that case. But you can use some "cin >> {declared_but_unused_variable};", which makes no sense to the program, so that Playground will ask for input.
+ 1
get
I know that, but Code Playground doesn't pop the input dialog up where I'm supposedly write a name to test
Do you get the input dialog to pop running the OP's code?
+ 1
Ipang, I thought that you did not get the point of "cin.getline". 😂
0
Ipang, no.
If you did not understand the last two sentences, there is an example: type `string __unused_string__; cin >> __unused_string__` after the "<int> main ()" function for input pop-up to be displayed.