摘要:
#include "stdio.h"void strcut(char *s, char *sub,int m, int n) //用参数sub来保存结果,所以函数不用返回值了{int i;for (i=0;i<n;i++)sub[i]=s[m+i-1];sub[i]='\0';}main(){char ps[20]; //用来保存截取子串的必须是数组,不能是指针static char s[]="goodmorning";strcut (s,ps,3,4);printf ("%s\n",ps);} 阅读全文
posted @ 2012-03-27 22:08
笑笑小白
阅读(1142)
评论(0)
推荐(0)
摘要:
传说这是一道很经典的面试题。很多童鞋都秉承正常人的思维,老老实实写下了倒转判断的代码。谁会想到用union呢?union有一个特性:其存放顺序是所有成员都从低地址开始存放。有没有一点灵感?其实什么是巧妙,就是利用融会贯通罢了。代码如下:?1234567891011121314151617181920212223#include <iostream>using namespace std;int checkCPU();int main(){if(checkCPU())cout << "你的CPU是小端机." << endl;else cou 阅读全文
posted @ 2012-03-27 14:34
笑笑小白
阅读(938)
评论(0)
推荐(0)
摘要:
下面为string.h文件中函数的详细用法,附加实例:1、strcpy 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include <stdio.h> #include <string.h> int main(void) { char string[10]; char *str1 = "abcdefghi"; stpcpy(string, str1); printf("%s\n", string); return 阅读全文
posted @ 2012-03-27 13:48
笑笑小白
阅读(2867)
评论(0)
推荐(0)
摘要:
string.h文件中函数的详细用法 下面为string.h文件中函数的详细用法,附加实例:1、strcpy 函数名: strcpy 功 能: 拷贝一个字符串到另一个 用 法: char *strcpy(char *destin, char *source); 程序例: #include <stdio.h> #include <string.h> int main(void) { char string[10]; char *str1 = "abcdefghi"; strcpy(string, str1);printf("%s\n" 阅读全文
posted @ 2012-03-27 11:57
笑笑小白
阅读(34588)
评论(4)
推荐(1)

浙公网安备 33010602011771号