Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to write a c program for display reverse string with characters "x" in between each character eg:(oxlxlxexh)
Posted
Updated 7-Jan-12 19:29pm
v2
Comments
Sergey Alexandrovich Kryukov 1-Jan-12 13:17pm    
Totally useless question to ask: there is no use of this functionality and no "professional secrets" to share. If this is used as a programming exercise, the answer would be useless anyway, as such exercise can only have some value if done with your own hands. Finally, if we consider such thing as school cheating... but no, I don't believe it could be your goal.

--SA
Albert Holguin 8-Jan-12 1:20am    
Not a useful question, but it's probably some sort of homework... gave OP some direction...
Albert Holguin 8-Jan-12 1:30am    
edit: changed the subject of the question to something applicable

For starters... C doesn't really have strings... strings are character arrays, which should make reversing even simpler (intuitively).

Think about it (pseudo-code)...
char word[]="hello";
/*
so the characters...
*/
word[0] = 'h', word[1] = 'e', word[2] = 'l', word[3] = 'l', word[4] = 'o'
/*
if you want to reverse that, what's the simplest way? ...::cough cough:: _index_ ::cough::
*/
word[4] = 'o', word[3] = 'l', ...
/*
Of course, you can add loops to make that more efficient code

Now to add the 'x' character, well, that's easy too... just transfer onto a larger array and add those extra characters into it...  to make it a bit more flexible, look at dynamic memory allocation of character arrays using malloc() and free()
*/
 
Share this answer
 
This is really a simple (I would say basic) task. You have just to read a good tutorial about C programming language and start coding. Then, if you have any problem feel free to post here specific questions here.
 
Share this answer
 
Comments
BrainlessLabs.com 11-Jan-12 1:42am    
I second that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900