Character Pointers and Functions.c
程序员文章站
2022-03-11 18:41:17
...
What will be the output of the following C code?
Question 1:
// Date:2020/4/3
// Author:xiezhg5
#include <stdio.h>
#include <string.h>
int main(void)
{
char*str="hello, world\n";
char strc[]="good moring\n";
strcpy(strc,str);
printf("%s\n",strc);
return 0;
}
// hello, world
Question 2:
// Date:2020/4/3
// Author:xiezhg5
#include <stdio.h>
#include <string.h>
int main(void)
{
char str[]="hello, world\n";
str[5]='.';
printf("%s\n",str);
return 0;
}
// hello. world
Question 3:
// Date:2020/4/3
// Author:xiezhg5
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str="hello world";
char strary[]="hello world";
printf("%d %d\n",sizeof(str),sizeof(strary));
return 0;
}
// 4(32位系统) 12
Question 4:
// Date:2020/4/3
// Author:xiezhg5
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str="hello world";
char strary[]="hello world";
printf("%d %d\n",strlen(str),strlen(strary));
return 0;
}
// 11 11
Question 5:
// Date:2020/4/3
// Author:xiezhg5
#include <stdio.h>
#include <string.h>
void f(char *k)
{
k++;
k[2]='m';
printf("%c\n",*k);
}
int main(void)
{
char s[]="hello";
f(s);
return 0;
}
// e
Question 6:
// Date:2020/4/3
// Author:xiezhg5
#include <stdio.h>
#include <string.h>
void f(char *k)
{
printf("%s\n",k);
}
int main(void)
{
char s[]="hello";
f(s);
return 0;
}
// hello
上一篇: php date函数怎么用
下一篇: Mysql多个条件查询去重数据
推荐阅读
-
ERROR: Illegal character in opaque part at index 2: F:\Android\.android\debug.keystore
-
SyntaxError: Non-ASCII character '\xe5' in file
-
SyntaxError: Non-ASCII character '\xe5' in file
-
关于mysql字符集设置了character_set_client=binary 在gbk情况下会出现表描述是乱码的情况
-
mysql-Error 1115 Unknow Character Set : utf8
-
Java基本类型包装类概述与Integer类、Character类用法分析
-
基于指针pointers和引用references的区别分析
-
基于指针pointers和引用references的区别分析
-
Postman请求后台报错:Invalid character found in method name. HTTP method names must be tokens
-
python中time.strftime不支持中文,报错UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2: encoding error