PDA

View Full Version : [SOLVED] hobby help..but please!



manyu29
March 17th, 2010, 09:06 AM
i have been trying to write a program which reverses a text entered,but i havent had any luck so far..could anybody give me a sample program or even a pseudocode?

derekeverett
March 17th, 2010, 09:11 AM
I'm no programming genius, but seems to me you could parse the string into a char array. Then count threw the array assigning the count value to an int.

Then loop through the array backwards using the array value of your int, decrementing the int by one at every loop iteration. This would print out the string backwards one char at a time.

manyu29
March 17th, 2010, 09:16 AM
how do i do the char array in nasm?im already having trouble using the [ebx]..it seems that im not doing it right..

derekeverett
March 17th, 2010, 09:18 AM
how do i do the char array in nasm?im already having trouble using the [ebx]..it seems that im not doing it right..

You got me there.

manyu29
March 17th, 2010, 09:23 AM
stil uve helpd me a lot..thx man

JoeWheeler
March 17th, 2010, 04:33 PM
What language are you using, this is reallly easy in python I'm not sure about other languages though

superarthur
March 17th, 2010, 07:33 PM
In Perl:

my $string = 'word';
$string = reverse $string;
print $string; #prints: drow
(even though the thread is [SOLVED], I couldn't resist. :P)

nvteighen
March 17th, 2010, 09:48 PM
how do i do the char array in nasm?im already having trouble using the [ebx]..it seems that im not doing it right..

Er... Why are you using NASM? Assembly is a language not meant for beginners... If you're a beginner, there are plenty of better languages to choose from; I recommend you Python, but look at the stickies and the lots of discussion about the topic in these forums.

schauerlich
March 17th, 2010, 10:17 PM
Er... Why are you using NASM? Assembly is a language not meant for beginners... If you're a beginner, there are plenty of better languages to choose from; I recommend you Python, but look at the stickies and the lots of discussion about the topic in these forums.

I'm guessing it's homework.

kaibob
March 19th, 2010, 05:21 AM
(even though the thread is [SOLVED], I couldn't resist. :P)

Me too!


#!/bin/bash

word=kaibob

i=${#word}

for ((j=1 ; j<=${i} ; j++)) ; do
echo -n ${word:(-${j}):1}
done

echo

Just for the record, the easiest solution is the rev utility:


$ rev <<< kaibob
bobiak