943,648 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 809
  • C RSS
Sep 15th, 2008
0

How the hell did i do this! funny as hell

Expand Post »
run it type hello, press enter then type end in a c ompiler
  1. #include <stdio.h>
  2. #include "strlib.h"
  3. #include "simpio.h"
  4. #include "genlib.h"
  5. #include "string.h"
  6.  
  7. #define size 50
  8.  
  9. void reverse(char rev[]);
  10.  
  11. int main()
  12. {
  13. char rev[size], i;
  14.  
  15. printf("Please enter a sentence and end the sentence with a enter than end \n");
  16. reverse(rev);
  17. system("pause");
  18. }
  19.  
  20. void reverse(char rev[])
  21. {
  22. string ch;
  23. int i;
  24.  
  25. if(StringCompare((ch = GetLine()), "end") != 0)
  26. {
  27. for(i=1; i<StringLength(ch); i++)
  28. {
  29. rev[i] = IthChar(ch, i);
  30. }
  31. reverse(rev);
  32. }
  33. else;
  34.  
  35. for(i=48; i<size; i--)
  36. {
  37. if(rev[i] == 'end');
  38. else
  39. {
  40. printf("%c",rev[i]);
  41. }
  42. }
  43. }
Last edited by Ancient Dragon; Sep 15th, 2008 at 11:22 pm. Reason: add line numbers for convenience.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
plike922 is offline Offline
38 posts
since Jul 2008
Sep 15th, 2008
0

Re: How the hell did i do this! funny as hell

I don't know how you did it, but I do know the code you posted can't compile cleanly. For example the loop that starts on line 35 is all wrong. It could be written like this (or use whatever string comparison function you wish).
  1. for(i=48; i<size; i--)
  2. {
  3. if( strcmp(&rev[i], "end") != 0)
  4. {
  5. printf("%c",rev[i]);
  6. }
  7. }
Last edited by Ancient Dragon; Sep 15th, 2008 at 11:25 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,947 posts
since Aug 2005
Sep 15th, 2008
0

Re: How the hell did i do this! funny as hell

>How the hell did i do this! funny as hell
That's nothing! I'll tell you what would be funny as hell. A new commercial with Bill Gates and Jerry Seinfeld, playing on violin "Fiddler On The Roof", as they hand stand, naked, against the wall. Makes you wonder what they used to play the violin with, doesn't it?
Last edited by Aia; Sep 15th, 2008 at 11:38 pm.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Sep 16th, 2008
0

Re: How the hell did i do this! funny as hell

Click to Expand / Collapse  Quote originally posted by Aia ...
>How the hell did i do this! funny as hell
That's nothing! I'll tell you what would be funny as hell. A new commercial with Bill Gates and Jerry Seinfeld, playing on violin "Fiddler On The Roof", as they hand stand, naked, against the wall. Makes you wonder what they used to play the violin with, doesn't it?

Oh! that would be discusting, not funny. I posted a link to one of their commercial over in Geek's Lounge yesterday. They are anything but funny.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,947 posts
since Aug 2005
Sep 16th, 2008
0

Re: How the hell did i do this! funny as hell

Oh! that would be discusting, not funny.
C'mon, did you miss it? Don't you remember that in that musical there's a song titled: "If I were a rich man"
Oh well, “De gustibus et coloribus non disputandum est”
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: pseudocode help!
Next Thread in C Forum Timeline: Finding Coefficients of a polynomial, roots are provided from command line





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC