99问答网
所有问题
# include<stdio.h> # include<string.h> void main( ) {char s[]=“four”; strcpy(s,s+1); puts(s); }
作用: 子串s+1复制给s
即删除首字符
那么换成s+2呢
举报该问题
推荐答案 推荐于2017-08-22
# include<stdio.h>
# include<string.h>
void main( )
{
char s[]="four";
strcpy(s,s+2);
puts(s);
}
如果改成s+2,就是把子串s+2复制给s
即删除前两个字符
运行结果如下:
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://99.wendadaohang.com/zd/W7zOXeBXettXvjejXet.html
其他回答
第1个回答 2014-06-14
可以用strncpy (str1,str2,n)
第2个回答 2014-06-14
不是,他是哈利波特吗
相似回答
写出浮点数-101.1101二进制表示方法?
答:
可以用 union 方法输出各个字节的 2 进制形式。
include
<
stdio.h
> include <math.h> union uu { float f;unsigned
char
s[
4];} u
;void
char_to_2(unsigned char c, int v[8]){ int i,j;for (i=0; i<8;i++)v[i]=( c & (1 << (7-i))) >> (7-i);} int
main ()
...
学习C语言需要掌握哪些基本知识?
答:
#include
<
stdio.h
> int
main()
{
int age = 18; float height = 1.85;
char
unit = 'm'; printf("小明今年%d岁\n", age); printf("小明身高%f%c\n", height, unit); printf("小明现在在慕课网上学习IT技术\n
");
return 0; } 学好C++才是入职大厂的敲门砖! 当年要是有这课,我的C++也不至...
编写程序,输入一个字符串,将它逆序输出。
答:
include
<
stdio.h
> include <
string.h
> int
main(){ char
str[100];int i, len;printf("请输入一个字符串:
");
scanf("%s", str);len = strlen(str);printf("逆序输出的字符串为:");for (i = len - 1; i >= 0; i--){ printf("%c", str[i
]);
} return 0;} 程序首先从...
用c语言建立txt文件并写入和读出三个学生的姓名性别年龄家庭住址...
答:
include
<
stdio.h
> include<
string.h
> define N 3 struct MSTU
{ char
name[20],addr[80]; int age,sex; }
;void
main()
{ MSTU mstudent[N];int i,n;FILE *fp;char buffer[256],s[2][3]={ "女","男" },sex[20];strcpy(mstudent[0].name,"李明
");
mstudent[0].age=14; ...
C语言中十进制数和十六进制数能直接运算吗
答:
C语言程序中,十进制和十六进制实际是互通的。十六进制数由数字0~9、字母A~F(或a~f)组成。把十六进制数按权展开、相加即得十进制数。现实中十六进制数和十进制数不可以直接相加,如是在电脑上的话是可以的,何种进制数在电脑上都是以二进制的形式表示的,在电脑编写程序时是可以相加的。十进制数...
C语言-删除字符串中的字符。
答:
c语言中书写删除字符串中某个字符的程序的具体操作步骤如下:1、编写头函数,包括“
#include
<
stdio.h
>.”与“#include <
string.h
>.“。2、定义两个相同容量的字符串储存的变量
char
a【100】
;
char b【100】。以及整数变量 int c;int i=0,j=0;其中a[100]是存字符串的,b【100】是...
求运行结果,各位大神。
#include
<
stdio.h
>
void
main(
)
{
答:
include
<
stdio.h
>
void
main()
{ char
s[ ]=
“abcdef”; s[3]=‘\0’; printf("%s\n",s);}运行结果是输出:abc printf顺序输出字符数组中的字符,当遇到s[3]中存放的0时,认为字符串结束而停止输出返回,这时s数组中存放的数据为:'a','b','c','\0','e','f','\0'...
1.输入一个字符串(不超过50个字符
)
,内有数字和非数字字符 ,如: a_百 ...
答:
include <
stdio.h
>
#include
"
string.h
"int
main(void){ char
s[
51]; int d[25],i,j,k; printf("Please enter a string, the length <= 50...\ns
=");
if(!gets(s) && strlen(s)>50){ printf("Input error, exit...\n"); return 0; } for(j=i=...
如何用c语言读取文本文件中的多行数据
答:
1、用fgets函数可以读取文件中某行的数据,某列数据就必须一个一个读入每行的第几个字符,再存入到一个字符串当中。2、例程:include<
stdio.h
>
#include
<
string.h
>
void
main(){ char
a[100],b[100],c[100]; int i=3,j=4,k=0; //第三行,第四列 FILE *fp = fopen("data.tx...
大家正在搜
include iostream
include fstream
c语言include stdio
int main(void)
int main(void)含义
include string作用
include cstdio
visual studio
includestring
相关问题
#include<stdio.h> void main() ...
求改错,输入数字,然后输出,要求数字间要有空格#includ...
用c语言编写程序,将两个字符串连接起来,不要用strcat函...
c语言: #include"stdio.h" char *s...
C++改错:连接字符串
急急急!!!C语言编程题:编写函数strcat(char *...
#include<stdio.h> main() {char...
C语言编程:编一程序,将两个字符串联接起来,不要用Strca...