Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <string.h>
- #include <stdio.h>
- int main(){
- std::string name;
- std::string name2;
- printf("Print donald or larry: ");
- scanf("%s",name);
- if(strcmp(name.c_str(), "donald") == 1){
- printf("You entered donald");
- goto stop;
- }else{
- printf("You entered larry");
- goto stop;
- }
- stop:
- return 0;
- }
- error: cannot pass objects of non-trivially-copyable type 'std::string {aka
- class std::basic_string<char>}' through '...'|
- scanf("%s", name);
- #include <iostream>
- using std::cout;
- using std::endl;
- using std::cin;
- #include <string>
- using std::string;
- int main(){
- // declare the string object
- std::string name;
- // output prompt and get input
- cout << "Print donald or larry: ";
- cin >> name;
- if (name == "donald") {
- cout << "You entered donald" << endl;
- }
- else if (name == "larry") {
- cout << "You entered larry" << endl;
- }
- return 0;
- }
- std::string str(256, ' ');
- if (1 == scanf("%*s", &str[0], str.size())) {
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement