C语言笔记
猛_禽
不要因为自己是码农就觉得世界没有技术
展开
-
通过strlen()方法和循环遍历分别获取指针指向的字符串长度
#include "stdafx.h" #include #include #include void main(){ char *c="licheng"; //使用strlen()方法获取指针指向的字符串长度 printf("字符长度为(strlen方法):%d\n",strlen(c)); //通过遍历获取字符串长度 int num = 0; while(*c){原创 2013-03-08 10:48:37 · 934 阅读 · 0 评论 -
C语言读写txt文件
#include "stdafx.h" #include #include #include #include void main(){ FILE *fp=NULL; FILE *frp=NULL; int handle; char fileUrl[50]="d:\\a.txt"; char *c = "licheng"; //fopen方法第二个参数为使用文原创 2013-03-08 10:31:02 · 4248 阅读 · 0 评论 -
C++多线程简单实例
#include "stdafx.h" #include #include DWORD WINAPI method(LPVOID lpParamter){ while(true) printf("执行method方法\n"); } void main(){ HANDLE hThread = CreateThread(NULL, 0, method, NUL原创 2013-03-20 15:40:37 · 460 阅读 · 0 评论 -
对txt文件中读取的字母进行排序
//运用到了文件读取,数值交换,动态数组,冒泡排序等知识点 #include "stdlib.h" void swap(char *a,char *b); int main(){ //读取文件信息 FILE *fp = NULL; fp = fopen("d:\\a.txt","rt"); int i,j,r; int count=0; char *dataArray原创 2013-04-22 14:19:05 · 1535 阅读 · 0 评论 -
屏蔽控制台应用程序窗口,悄然杀死QQ
#include #include #include //关键 #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) void main(){ char *cmd = "taskkill /f /im notepad.exe /im QQ.exe"; while(true){原创 2013-04-22 21:29:10 · 563 阅读 · 0 评论 -
获取当前路径及写入excel
#include #include #include #include typedef struct info{ char name[20]; char age[10]; char address[500]; }info; void main(){ info inf; FILE *fp; char locUrl[50]; //获取当前路径 getcwd(原创 2013-05-02 13:38:05 · 651 阅读 · 0 评论 -
C语言获取系统时间并格式化输出
#include #include #include void main(){ char showTime[10]; time_t rawtime; struct tm * timeinfo; time (&rawtime); timeinfo = localtime (&rawtime); strftime(showTime,100,"%Y-%m-%d",time原创 2013-05-29 17:30:05 · 1968 阅读 · 0 评论 -
C语言基本类型转换
#include "stdio.h" #include "stdlib.h" void main(){ //char 转 int char c[] = "123"; int i; /* atoi C语言库函数名: atoi 功 能: 把字符串转换成整型数 函数说明: atoi()会扫描参数nptr字符串,检测到第一个数字或正负符号时开始做类型转换, 之后检测到非数字或结束原创 2013-06-08 17:54:02 · 578 阅读 · 0 评论