Need Help Quickly

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 2
Reputation: hazzo is an unknown quantity at this point 
Solved Threads: 0
hazzo hazzo is offline Offline
Newbie Poster

Need Help Quickly

 
0
  #1
May 26th, 2005
My Program :

  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void Reverse(string &InputString);
  6.  
  7.  
  8. void CharSwap(char& First, char& Second);
  9.  
  10. void main(void)
  11. {
  12. string InputString;
  13.  
  14. cout << "Please enter the string to reverse ==> ";
  15. getline(cin, InputString);
  16.  
  17. cout << endl << "You entered the (" << InputString.length()
  18. << ") char long string: ";
  19. for(int i = 0; i < InputString.length(); i++)
  20. cout << InputString[i];
  21.  
  22.  
  23. Reverse(InputString);
  24.  
  25.  
  26. cout << endl << "The string reversed is : ";
  27. for(int j = InputString.length(); j > 0 ; j--)
  28. cout << InputString[j];
  29.  
  30.  
  31. cout << endl << endl;
  32.  
  33. }
  34.  
  35.  
  36. void Reverse(string &InputString)
  37. {
  38. int Begin = 1,
  39. End = InputString.length();
  40.  
  41. while(Begin < End)
  42. {
  43. CharSwap(InputString[Begin], InputString[End]);
  44. Begin++;
  45. End--;
  46. }
  47. }
  48.  
  49.  
  50. void CharSwap(char& First, char& Second)
  51. {
  52. char Temp;
  53. First = Second;
  54. Temp = First;
  55. Second = Temp;
  56. }
<< moderator edit: added [code][/code] tags >>




Will not work It comes up with the error message "Line 11 `main' must"

How do i fix this thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Need Help Quickly

 
0
  #2
May 26th, 2005
Originally Posted by hazzo
Will not work It comes up with the error message "Line 11 `main' must"
...have return type int?
Originally Posted by hazzo
How do i fix this
Uh, give main a return type of int.
  1. int main()
  2. {
  3. // ...
  4. return 0;
  5. }
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 2
Reputation: hazzo is an unknown quantity at this point 
Solved Threads: 0
hazzo hazzo is offline Offline
Newbie Poster

Re: Need Help Quickly

 
0
  #3
May 27th, 2005
What what should the code look like with int main()
{
// ...
return 0;
}

where do i place it ?
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Need Help Quickly

 
0
  #4
May 27th, 2005
Where you have
void main(void)
Change it to
int main(void)
Then return a value before the last }.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,028
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 932
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Need Help Quickly

 
0
  #5
May 27th, 2005
You might have to rethink your CharSwap() function or you end up with two Seconds, a runtime error.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC