三九宝宝网宝宝教育教学论文

C语言字符串数组

02月18日 编辑 39baobao.com

[C语言字符串数组反转相关的问题]c语言的问题字符串反转可以使用下列两种方法: 使用Array.Reverse方法 对于字符串反转,我们可以使用.NET类库自带的Array.Reverse方法 public static string ReverseByArray(st...+阅读

#include

main()

{

char c[]="pascal program";

gets(c);

printf("%s",c);

}

这个可以的,如果你一定要用sanf输出i am a boy,这样吧:

#include

main()

{char c1[10],c2[10],c3[10],c4[10];

scanf("%s%s%s%s",c1,c2,c3,c4);

printf("%s %s %s %s",c1,c2,c3,c4);

}

因为输入i am a boy,实际上是四个字符串。以空格为字符结束,系统自动加上'/0'进行存储。如果输入其他四个字符串的也可以。

以下为关联文档:

C语言怎么将字符串数组元素进行逆转#include<stdio.h> #include<stdlib.h> #include<string.h> int main(void) { char str[80]; int i,j; char ch,*p=str; printf("输入字符串:"); gets(str); for(i=0,j=strlen(str...

c语言中指针数组字符串数组的区别高手请进!#include "stdio.h" #include "string.h" void shellsort(char v[][10], int n); void writeline(char linp[][10],int n); main() { char line[][10]={"C++","Fortran","Basic","Pasca...

C语言定义全局字符串二维数组帮你写了一个: #include <stdio.h> char name[10][20]; void inPut() { int i; printf("请输入十个学生的名字!\n"); for (i=0; i<10; i++) { scanf("%s", &name[i]); } } void outP...

C语言整数数组转化为字符串C有“整数数组转化为字符串”的专用库函数char *itoa(int num,char *str,int radix)。声明一个存放转换后的字符串的二维字符数组,将整型数组的元素作为num来调用itoa函数,将...

C语言传字符串数组当指针用 // aa.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; void fu(char *buf) { str...

C语言字符串数组字典排序用二维数组记录书名,再声明一个指针数组并使各元素分别指向各书名,然后对指针数组元素按其指向的书名的字典顺序排序。这样比直接拷贝书名的效率会高些。举例如下: //#include...

c语言字符串数组排序#include <stdio.h> #include<string.h> main() { char*p_str[8]={"Paris","York","London","Shanghai","Edo","Taipei","Beijing","Singapore"},*temp; int i,j; for(i=0;i<7;i++)//冒泡法...

C语言通用函数字符指针数组寻找指定字符串#includenbsp;“stdafx.h“#includenbsp;amp;lt;stdio.hamp;gt;#includenbsp;amp;lt;string.hamp;gt;intnbsp;str2str(constnbsp;charnbsp;*str,nbsp;constnbsp;charnbsp;*s...

C语言字符数组C语言中没有字符串的数据类型,而字符串的处理又非常频繁,为便于字符串的操作,C语言引入字符数组,用于存储字符串内容。 举例: main() { char ch[20]; int i; printf("Input:"); for...

推荐阅读
图文推荐