终极解决方案:
VS2010在经历一些更新后,建立Win32 Console Project时会出“error LNK1123” 错误,
解决方案为 将 项目|项目属性|配置属性|清单工具|输入和输出|嵌入清单 “是”改为“否”即可,但是每新建一个项目都要这样设置一次,很麻烦
在建立VS2010 Win32 Project项目时,按照上面解决方案依然发生了“error LNK1123”错误,经过上网查资料,解决方案为:
终极解决方案:
VS2010在经历一些更新后,建立Win32 Console Project时会出“error LNK1123” 错误,
解决方案为 将 项目|项目属性|配置属性|清单工具|输入和输出|嵌入清单 “是”改为“否”即可,但是每新建一个项目都要这样设置一次,很麻烦
在建立VS2010 Win32 Project项目时,按照上面解决方案依然发生了“error LNK1123”错误,经过上网查资料,解决方案为:
code:
//字符输入 #include <curses.h> main() { int ch; int x=5,y=5; initscr(); keypad(stdscr,TRUE); curs_set(0); noecho(); mvaddch(y,x,'A'); while(1) { ch=getch(); //mvaddch(y,x,' '); //clrtoeol(); erase(); //clear(); switch(ch) { case KEY_UP: y--; break; case KEY_DOWN: y++; break; case KEY_LEFT: x--; break; case KEY_RIGHT: x++; break; } mvaddch(y,x,'A'); refresh(); } endwin(); } //字符串输入 #include <curses.h> main() { char name[9]={0}; int r; initscr(); //绘制UI mvaddstr(4,10,"用户:[ ]"); //输入 r=mvgetnstr(4,16,name,8); //name[r]=0; //打印输入 mvprintw(7,10,"你输入的是:%s",name); refresh(); //输入字符 getch(); endwin(); } //格式输入 #include <curses.h> void init(); void drawUi(); void dealInput(); void destroy(); main() { init(); drawUi(); dealInput(); destroy(); } void dealInput() { int a,b; while(1) { mvaddstr(2,3," "); mvscanw(2,3,"%d",&a); mvaddstr(2,11," "); mvscanw(2,11,"%d",&b); mvaddstr(2,19," "); mvprintw(2,19,"%d",a+b); refresh(); } } void drawUi() { mvaddstr(2,2,"[ ]+[ ]=[ ]"); refresh(); } void destroy() { endwin(); } void init() { initscr(); }
code:
#include <curses.h> #include <time.h> #include <unistd.h> void init(); void drawui(); void business(); void destroy(); main() { init(); drawui(); business(); destroy(); } void business() { time_t tt; struct tm *t; while(1) { //取时间 tt=time(0); t=localtime(&tt); //显示时间 mvprintw(LINES/2,(COLS-8)/2, "%02d:%02d:%02d", t->tm_hour,t->tm_min,t->tm_sec); //刷新屏幕 refresh(); sleep(1); } } void drawui() { box(stdscr,0,0); } void destroy() { endwin(); } void init() { initscr(); }
code:
#include<curses.h> /* 在initscr();后调用。 终端是否支持颜色:bool has_colors(); 初始化颜色:int start_colors(); 定义颜色对:int init_pair(short pair,short fore,short back); 使用颜色对:COLOR_PAIR(short pair); */ int main() { WINDOW *w=initscr(); if(has_colors()==TRUE) { start_color(); init_pair(1,COLOR_RED,COLOR_WHITE); init_pair(2,COLOR_RED,COLOR_GREEN); bkgd(COLOR_PAIR(2));//整体颜色 } border(0,0,0,0,0,0,0,0); box(stdscr,0,0);//画边框,0都代表系统默认格式 mvhline(2,10,'=',20);//第几行第几列输出多少个字符 //mvhline(2,10,'|',20); mvaddch(3,10,'A'|A_BOLD|A_UNDERLINE|COLOR_PAIR(1));//指定位置输出字符//man attron attron(COLOR_PAIR(1));//开启属性 mvaddstr(5,10,"hello");//输出字符串 attroff(COLOR_PAIR(1));//关闭属性 mvprintw(9,10,"行:%d,列:%d",LINES,COLS);//格式字符输出到窗口 refresh();//刷屏,显示效果 //wrefresh(WINDOW *w); getch(); endwin(); return 0; }
code:
#include<stdio.h> #include<stdlib.h> #include<fcntl.h> int a=6666; main() { char filename[100]; int fd; int data; sprintf(filename,"/proc/%d/mem",getpid());//本程序虚拟内存文件 fd=open(filename,O_RDWR); if(fd==-1) printf("open error:%m\n"),exit(-1); pread(fd,&data,4,(off_t)&a);//从虚拟内存的相同地址中,读取实际地址位置相同的数据到data中 //pread() = lseek()+read() //lseek(fd,(off_t)&a,SEEK_SET); //read(fd,&data,4); printf("%d\n",data); close(fd); }
code:
#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<fcntl.h> #include<sys/stat.h> #include<string.h> #include<sys/mman.h> struct stu { char name[20]; int age; float score; }; //1 打开文件,2 映射到虚拟地址,3 写入数据,4 卸载虚拟地址,5关闭文件 main() { int fd; struct stu *s; struct stat st; int size; int count; struct stu record; memset(&record,0,sizeof(struct stu)); fd=open("newstu.dat",O_RDWR|O_CREAT|O_EXCL,0666); if(fd==-1) { fd=open("newstu.dat",O_RDWR); if(fd==-1) printf("::%m\n"),exit(-1); } fstat(fd,&st); size=st.st_size;//原大小 count=size/sizeof(struct stu); ftruncate(fd,size+sizeof(struct stu));;//改变文件大小,在munmap前调用就行,+ 就是增大,-就是减小 s=mmap(0,size+sizeof(struct stu), PROT_READ|PROT_WRITE, MAP_SHARED,fd,0); //* printf("输入姓名:"); scanf("%s",s[count].name); printf("输入年龄:"); scanf("%s",&(s[count].age)); printf("输入分数:"); scanf("%f",&(s[count].score)); //*/ int i; for(i=0;i<count-1;i++) { printf("%s,%d,%.2f\n",s[i].name,s[i].age,s[i].score); } munmap(s,size+sizeof(struct stu)); close(fd); }
//iotool.c
#include <stdio.h> int inputInt(const char *info) { int r; printf("%s:",info); scanf("%d",&r); return r; }
graphic.c
iterator.cpp
/* 迭代器 输入:可读,不一定可改值 输出:可改,不一定可读值 前向:可读可改 双向:支持 -- 随机:支持--、+n、-n、下标访问 */ #include<iterator> #include<iostream> using namespace std; #include<algorithm> #include<vector> #include "print.h" #include<fstream> int main() { //输入迭代 istream_iterator<int> in(cin);//输入流cin,也可以是文件输入流 istream_iterator<int> end; vector<int> vi; copy(in,end,back_inserter(vi));//一直输入,按ctrl+D结束 print(vi.begin(),vi.end()); //输出迭代 ofstream fo("out.txt"); ostream_iterator<int> o(cout,","); ostream_iterator<int> ofile(fo," "); copy(vi.begin(),vi.end(),o); copy(vi.begin(),vi.end(),ofile); fo.close(); cout<<endl; }
//specialcontainer.cpp
/*一般容器:stack,queue 特殊容器:priority_queue .push(element),.pop(),.empty() stack:.top() queue:.front(),.back() priority_queue:.top() 没有迭代器 */ #include<iostream> #include<queue> using namespace std; int main() { priority_queue<int> pq; pq.push(40); pq.push(20); pq.push(10); pq.push(50); pq.push(90); while(!pq.empty()) { cout<<pq.top()<<' '; pq.pop(); } cout<<endl; return 0; }
print.h
//print.h #include <iostream> using namespace std; #ifndef print_fun #define print_fun template<typename T> ///显示序列数据 void print(T b,T e,char c=' ') { bool isExit=false; while (b!=e) { cout<<*b++<<c; isExit=true; } if(isExit) cout<<endl; } template<typename K,typename V> ostream& operator<<(ostream& o,const pair<K,V>& p)//重载输出map类型元素 { return o<<p.first<<':'<<p.second; } #endif