answersLogoWhite

0

{

// get input

char input[256];

gets(input);

// reverse it

char reverse[256];

strReverse(input, reverse);

}

// reverses str and puts the result in buff

// NOTE: buff must be at least as large as str

void strReverse(const char* str, char* buff) {

const int length = strlen(str);

// special case for zero-length strings

if( length == 0 ) {

return;

}

// reversify

int i;

for(i = 0; i < length; ++i) {

buff[i] = str[length - i - 1];

}

buff[i] = '\0';

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Can you provide an example of how to use the keyword "headstring" in a programming function?

In programming, the keyword &quot;headstring&quot; can be used to extract a specific number of characters from the beginning of a string. For example, in a function that takes a string as input and uses &quot;headstring&quot; to extract the first 5 characters, the code might look like this: python def extractheadstring(inputstring): head inputstring:5 return head In this function, the &quot;headstring&quot; keyword is used to extract the first 5 characters from the input string and return them as a new string.


Program to reverse string in perl?

To reverse a string in Perl, you can use the reverse function along with split to break the string into individual characters, and then join them back together. Here’s a simple example: my $string = &quot;Hello, World!&quot;; my $reversed = join('', reverse split('', $string)); print $reversed; # Output: !dlroW ,olleH This code splits the string into characters, reverses the list of characters, and then joins them back into a single string.


How do I reverse a String and at the same time delete one letter (until all what's left is a single letter) using loops (JAVA)?

I have some knowledge of programming but I'm unsure of anything in java, my explanation is created out of my understanding of JavaScript. I will try to express variables within parenthesis () Reversing The Input (assuming you know how to retrieve user input) My suggestion is to create a variable named (i) and set it to the length of a variable called (string),// the user's input //, and create a loop repeating length of (string) times, where each time through variable (i) changes by - (1), and join letter (i) of (string) to a new variable (reversed_string), and you have the reversed the string. Taking away last letter each time Reposted, if image doesn't show I'll try to explain it. The code is based on JavaScript language


What is a format specifier?

There are many types of format specifier. Exp:%d (To show the integer) %c(To show the character) %f(Float are digits with decimal points to use it to show them) %s(String to show the string)


Anyone knows a programming code to look for nth word in a string using string.h?

Function strtok can help you to separate the words.


Print reverse string in c sharp?

To print a reverse string in C#, you can use the Array.Reverse method or LINQ. Here's a simple example using Array.Reverse: string original = &quot;Hello, World!&quot;; char[] charArray = original.ToCharArray(); Array.Reverse(charArray); string reversed = new string(charArray); Console.WriteLine(reversed); This code converts the string to a character array, reverses the array, and then creates a new string from the reversed array before printing it.


Sample code in java programming?

public class Hello { public static void main (String args[]) { System.out.println("Hello World"); } }


How the pin no is generated in the ATM?

there is a programming code for it which takes 16 digit as input , plays with it in a c programme and gives a 4 digit output...........


Vb net code for to get last 6 digits when gave more than 6 degits?

Dim input As String Dim inputNum As Integer 'Get input input = Console.ReadLine() 'Convert input to number and chop off all but the last 6 digits inputNum = Integer.Parse(input) Mod 1000000 'Display parsed input Console.WriteLine(inputNum)


What is irvine32?

Irvine32 is a library designed for assembly language programming, particularly in the context of the x86 architecture. It provides a set of procedures and macros that simplify tasks such as input/output operations, string handling, and mathematical computations, making it easier for students and programmers to write assembly code. The library is often used in educational settings, especially in courses that teach low-level programming concepts using the MASM assembler.


What is the Programming code for shortest job first?

What is the Programming code for shortest job first?


What do you call the translator which takes Assembly languages program input?

The translator that takes assembly language as input is called an assembler. An assembler converts assembly language code, which is a low-level programming language, into machine code or object code that can be executed by a computer's processor. This process is essential for enabling the execution of programs written in assembly language.