String reverse output, requires calling function to implement __ function

Source: Internet
Author: User

Simple, requires calling function implementation

#include <stdio.h>
#include <string.h>
void inv (char S1[],char s2[])
{
int l,i;
L = strlen (S1);
for (i = l-1;i >= 0;i--)
{
s2[l-i-1] = s1[i];
int main ()
{
int i;
Char s1[100] = {0},s2[100] = {0};
while (~SCANF ("%s", S1))
{
inv (S1,S2);
for (i = 0;i < strlen (S2); i++)
{
printf ("%c", S2[i]);
//for (i = strlen (S1) -1;i >= 0;i-) printf ("%c", s1[i);//puts (S2)
;        printf ("\ n");
Puts ("");
}
}

Here's a pit, here. Read the string do not use the gets function, will read out a space, scanf does not exist this problem.

In addition, to avoid the array output garbled, it is necessary to initialize the string array when defining it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.