Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <string>
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. int main(){
  6. std::string name;
  7. std::string name2;
  8.  
  9. printf("Print donald or larry: ");
  10. scanf("%s",name);
  11.  
  12. if(strcmp(name.c_str(), "donald") == 1){
  13. printf("You entered donald");
  14. goto stop;
  15.  
  16.  
  17. }else{
  18. printf("You entered larry");
  19. goto stop;
  20. }
  21.  
  22.  
  23.  
  24. stop:
  25. return 0;
  26. }
  27.  
  28. error: cannot pass objects of non-trivially-copyable type 'std::string {aka
  29. class std::basic_string<char>}' through '...'|
  30.  
  31. scanf("%s", name);
  32.  
  33. #include <iostream>
  34. using std::cout;
  35. using std::endl;
  36. using std::cin;
  37. #include <string>
  38. using std::string;
  39.  
  40. int main(){
  41.  
  42. // declare the string object
  43. std::string name;
  44.  
  45. // output prompt and get input
  46. cout << "Print donald or larry: ";
  47. cin >> name;
  48.  
  49. if (name == "donald") {
  50. cout << "You entered donald" << endl;
  51. }
  52. else if (name == "larry") {
  53. cout << "You entered larry" << endl;
  54. }
  55.  
  56. return 0;
  57. }
  58.  
  59. std::string str(256, ' ');
  60. if (1 == scanf("%*s", &str[0], str.size())) {
  61. // ...
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement