Outline ·
[ Standard ] ·
Linear+
How to reverse a phrase!? Help!, use reverse iterator?
|
TSukiya
|
Mar 2 2006, 01:34 PM, updated 20y ago
|
|
Need help !!! In C program, how to reverse a sentence like "Games" become "semaG"? How? can anyone teach me ? if can, give me the source code as well ! thanks!
not realli need to use reverse iterator, u can tell us how to use other function oso ! thanks
|
|
|
|
|
|
nxfx
|
Mar 2 2006, 02:10 PM
|
|
put the string into array and print it out backward.
|
|
|
|
|
|
TSukiya
|
Mar 2 2006, 02:23 PM
|
|
can u provide de source code as well? thanks
|
|
|
|
|
|
earl-ku
|
Mar 2 2006, 02:23 PM
|
|
declare 2 similiar long string to hold the word, use the last in first out method to place the particular word into the 2nd string, then print them on screen
|
|
|
|
|
|
TSukiya
|
Mar 2 2006, 02:35 PM
|
|
thanks for your idea... i m juz not very gud in source code... there's way i need help here ! can provide?
|
|
|
|
|
|
nxfx
|
Mar 2 2006, 02:49 PM
|
|
It's been quite sometime since I've done C, well here goes....
char str[10];
str = "Games";
for(i=len(str) ;i >=0 ; i--) { printf("%c",str[i]); }
|
|
|
|
|
|
dstl1128
|
Mar 2 2006, 02:52 PM
|
|
Use strrev().
|
|
|
|
|
|
TSukiya
|
Mar 2 2006, 02:59 PM
|
|
thanks ! any other idea or source code can provide to do this question ?
|
|
|
|
|
|
nxfx
|
Mar 2 2006, 03:00 PM
|
|
strrev() is not part of ANSI C, he may not able to use it.
|
|
|
|
|
|
silverhawk
|
Mar 2 2006, 03:11 PM
|
Eyes on Target
|
Code it out yourself. Don't be a friggin lazy arse hoping for someone to provide you a full answer immediately. People have already told you how you can do it, just implement it yourself. If you are unable to do such a simple task, i wonder why you're even learning how to program in the first place...
nxfx, you should not have posted the source code for him. We should not be encouraging this sort of behavior among programmers... let him show some effort and then guide him. If he does not show any effort himself, we should not waste any effort on him either.
|
|
|
|
|
|
naim_mahmood
|
Mar 2 2006, 03:20 PM
|
Getting Started

|
I hope i'm not too late this is actually the concept of omg i forgot the name CODE #include "stdio.h"
void reverse() { char ch; scanf("%c",&ch); if(ch != 'p') reverse(); printf("%c",ch); }
int main() { reverse(); getch(); }
|
|
|
|
|
|
naim_mahmood
|
Mar 2 2006, 03:22 PM
|
Getting Started

|
oops... sorry.... i din know cannot post answer
|
|
|
|
|
|
TSukiya
|
Mar 2 2006, 03:36 PM
|
|
QUOTE(silverhawk @ Mar 2 2006, 03:11 PM) Code it out yourself. Don't be a friggin lazy arse hoping for someone to provide you a full answer immediately. People have already told you how you can do it, just implement it yourself. If you are unable to do such a simple task, i wonder why you're even learning how to program in the first place... I oledi told u, if i know how to program in the first place! I wont ask u !!! I here juz wanna get some idea of the code ...
|
|
|
|
|
|
fly
|
Mar 2 2006, 04:18 PM
|
¯\(°_o)/¯
|
QUOTE(ukiya @ Mar 2 2006, 03:36 PM) I oledi told u, if i know how to program in the first place! I wont ask u !!! I here juz wanna get some idea of the code ... If you don't know how to program, then what is the source code going to be used for?
|
|
|
|
|
|
silverhawk
|
Mar 2 2006, 07:40 PM
|
Eyes on Target
|
QUOTE(ukiya @ Mar 2 2006, 03:36 PM) I oledi told u, if i know how to program in the first place! I wont ask u !!! I here juz wanna get some idea of the code ... Get some idea? Reversing the string is incredibly easy... but if you didn't know how to do it and wanted some guidance that isn't so bad. However your question was answered in the 2nd post, but you wanted the source code. Then example codes were given later by other people and you still wanted the source code. Its pretty obvious all you want is a direct working solution so you can copy and paste. If you still say you don't know how to do it, you got bigger issues to tackle than reversing a string. Go read up on arrays and loops.
|
|
|
|
|