Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. struct Person
  7. {
  8. char name[20];
  9. int age;
  10. };
  11.  
  12. Person new_person(char *argv);
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16.  
  17. if (argc < 3) // if its not 3 inputs including the command , result in error
  18. {
  19. cout << "You didn't give enough input information for this to run." << endl;
  20. return 0;
  21. }
  22. else if (argc > 3) // if its not 3 inputs including the command resuls in error
  23. {
  24. cout << "You put too many inputs for this program to run." << endl;
  25. return 0;
  26. }
  27.  
  28. Person input_Person;
  29. input_Person = new_person(*argv);
  30. cout << "The person's name is " << input_Person.name << " and that person is " << input_Person.age << " years old." << endl;
  31.  
  32. return 0;
  33. }
  34.  
  35. Person new_person(char *argv)
  36. {
  37. Person person;
  38.  
  39. strcpy (argv[1],person.name);
  40.  
  41. person.age = argv[2];
  42.  
  43. return person;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement