华清远见c语言学习笔记一
2012-07-06 20:28
155 查看
/*
* test.c
*
* Created on: Jul 6, 2012
* Author: 孙旭
* 华清实验室
*/
/*********1**********/
#include<stdio.h>
static void fun(); //加static表示只能在该文件下使用fun()函数
void fan();
int main()
{
fun();
return 0;
}
void fan()
{
printf("this is fan()\n");
}
static void fun()
{
fan();
printf("this is fun()\n");
}
*******2********
#include<stdio.h>
int main()
{
printf("asdffgyhgfsdfsdf"); //可以使用printf("字符串/字符串变量")直接打印
return 0;
}
/********3*********/
#include<stdio.h>
#include<stdlib.h>
int main()
{
int k;
k=true; //‘true’ undeclared (first use in this function)
printf("%d",k); //在c语言中不能直接使用true/false编译器不识别
return 0;
}
/********4*********/
#include<stdio.h>
#include<string.h>
int main()
{
string h="sdfdfg"; //Multiple markers at this line
puts(h); //在c语言中不能使用string字符串,这是c++中的
return 0;
}
/********5*********/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char a[34]="abcde";
char b[]="fght";
char *c;
int i=sizeof(c); //指针的长度都是4
printf("%d\n",i);
printf("strcat=%s\n",strcat(a,b)); //把b连接到a的后面返回的是a的地址
printf("strcpy=%s\n",strcpy(a,b)); //把b整体拷贝到a中
printf("strnpy=%s\n",strncpy(a,b,2)); //把b中的前两二字符拷贝到a中的前两个字节
int k;
int j;
int h;
j=strlen(a); //使用strlen()函数测字符串实际长度,遇到‘\0‘就结束
k=strcmp(b,a); //使用strcmp函数比较大小,b大于a返回1,b小于a返回-1,b等于a返回0
h=sizeof(a); //使用sizeof()函数测存储空间的长度
printf("sizeof=%d\n",h);
printf("strcmp=%d\n",k);
printf("strlen=%d\n",j);
return 0;
}
* test.c
*
* Created on: Jul 6, 2012
* Author: 孙旭
* 华清实验室
*/
/*********1**********/
#include<stdio.h>
static void fun(); //加static表示只能在该文件下使用fun()函数
void fan();
int main()
{
fun();
return 0;
}
void fan()
{
printf("this is fan()\n");
}
static void fun()
{
fan();
printf("this is fun()\n");
}
*******2********
#include<stdio.h>
int main()
{
printf("asdffgyhgfsdfsdf"); //可以使用printf("字符串/字符串变量")直接打印
return 0;
}
/********3*********/
#include<stdio.h>
#include<stdlib.h>
int main()
{
int k;
k=true; //‘true’ undeclared (first use in this function)
printf("%d",k); //在c语言中不能直接使用true/false编译器不识别
return 0;
}
/********4*********/
#include<stdio.h>
#include<string.h>
int main()
{
string h="sdfdfg"; //Multiple markers at this line
puts(h); //在c语言中不能使用string字符串,这是c++中的
return 0;
}
/********5*********/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char a[34]="abcde";
char b[]="fght";
char *c;
int i=sizeof(c); //指针的长度都是4
printf("%d\n",i);
printf("strcat=%s\n",strcat(a,b)); //把b连接到a的后面返回的是a的地址
printf("strcpy=%s\n",strcpy(a,b)); //把b整体拷贝到a中
printf("strnpy=%s\n",strncpy(a,b,2)); //把b中的前两二字符拷贝到a中的前两个字节
int k;
int j;
int h;
j=strlen(a); //使用strlen()函数测字符串实际长度,遇到‘\0‘就结束
k=strcmp(b,a); //使用strcmp函数比较大小,b大于a返回1,b小于a返回-1,b等于a返回0
h=sizeof(a); //使用sizeof()函数测存储空间的长度
printf("sizeof=%d\n",h);
printf("strcmp=%d\n",k);
printf("strlen=%d\n",j);
return 0;
}
相关文章推荐
- 华清远见C语言学习笔记九
- 华清远见C语言学习笔记十
- 华清远见c语言学习笔记三
- 华清远见c语言学习笔记四
- STL学习笔记----C++的新语言特性
- C语言学习笔记及感想 day1
- C# 3.0语言增强学习笔记(一)
- iOS学习笔记---oc语言第七天
- c语言学习笔记一
- Haskell语言学习笔记(40)Arrow(1)
- 80x86汇编语言学习笔记(四)
- CentOS学习笔记(一):中文语言包及输入法的安装使用
- R语言学习笔记:缺失值的判断与处理
- R语言学习笔记之<在Linux上遇到的问题集锦>
- 编译原理学习笔记(二)——高级语言及其语法描述
- C语言学习笔记(四)——数组和指针
- c语言之指向字符串的指针学习笔记
- 程序语言的奥妙 算法解读 日本人编著,自己学习笔记
- C语言学习笔记----伊能C语言学习笔记---*号的作用
- go语言学习笔记-接口学习