当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

C程序字符串倒序输出

更新:01-02 整理:39baobao.com
字体:

[C语言字符串连接问题]Please input str1:123 Please input str2:456 123456 Press any key to continue #include <stdio.h> char*mystrcat(char*str1,char*str2); void main() { char str1[50];...+阅读

你的函数没有返回值。

把a,b两个数组设为全局变量就好了。

就这样就行了:

#include "stdio.h"

char a[20],b[20];

char str(char a[],char b[])

{

int m=19,n;

for(n=0;m>-1;n++)

{

if(a[m]!='\0')

b[n]=a[m];

else b[n]=' ';

m--;

}

}

void main()

{

scanf("%s",a);

str(a,b);

printf("%s\n",b);

}

本文地址:https://www.39baobao.com/show/29_20187.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

C语言函数字符串截取分割C标准库中提供了一个字符串分割函数strtok(); 实现代码如下: #include <stdio.h> #include <string.h> #define MAXSIZE 1024 int main(int argc, char * argv[]) { char dat...

C语言字符串使用strtok函数分割之后字符串在内存中位置是否有改变char buf[20] = "abc def mmmm"; char *p = strtok(buf," "); printf("buf=%s\n",buf); printf("p_addr=%p\n",p); printf("buf_addr=%p\n",buf); 输出:buf=abc,说明切割后buf中的第一个...

c语言倒序输出字符串1 2 3 4 5 6 7 8 9 10 11 12 #include<stdio.h> #include<string.h> intmain () { charstring[100]; inti; charc; gets(string); for(i=strlen(string);i--;)//<----------...

C语言中的倒序输出#include<stdio.h> #include<string.h> #include<conio.h> void main() { int i; char *ch; ch=NULL; clrscr(); scanf("%s",ch); for(i=strlen(ch)-1;i>=0;i--) printf("%c",ch...

C语言字符串反转逆序输出已改,看注释 #include #include int main() { char a[31][31],*start,*end; int i=0,t,len,k=0; while(gets(a[i])!=NULL) { len=strlen(a[i]); start=a[i];end=&a[i][len-1]...

请教C语言字符串倒序输出#include<stdio.h> #include<string.h> void main() { char string1[200]; //用于存放输入的字符串 char string2[200]; //用于存放倒序后的字符串 int invertion(char *ch1,...

如何用C语言将字符串逆序输出C语言程序如下: #include<stdio.h> #include<string.h> main() { int i,j,t,n; char a[10]; printf("请输入2113字符串:"); gets(a); n=strlen(a); for(i=0;i<=n/2;i++) { t=a[i];...

C语言递归倒序输出字符串#include<stdio.h> void f() { char ch; if((ch = getchar())!='\n') f(); if(ch!='\n') printf("%c", ch); //这个输出语句是写在了递归调用之后,会被压栈,先压栈的后输出,所以可...

C语言怎么把带有空格的字符串倒序输出 # include "stdio.h" void out(char *s) { char *p; for(p=s; *p&*p!=' ';)p++; if(*p)out(++p); for(; *s&*s!=' ';)putchar(*s++); putchar(' '); } int main() { char s[2...