c program
共 6 篇文章
fstream 文件流 操作
文件流 借助与 fstream 1. 示例代码 #include <iostream.h> #include <fstream.h> using namespace std; int main() { ofstream data; data.open("./data.txt"); if(!data.is_open()){ cout << "couldnot open ./data.txt" << endl; } data <<"Hello ofstream"<<endl; data << "line 1:" << "it's line 1, griffin!" << endl; data <…
2010-05-06 11:56 · c program
info output w/ level
带leve 信息输出 直接上代码 #include <stdio.h> #include <stdarg.h> #define Error 0 #define Warning 1 #define Debug 2 #define Info 3 #define NOW Debug int gErrorMsg(char* fmt,...){ va_list vl; va_start(vl,fmt); if(NOW <= Error){ printf("[Error]"); vfprintf( stdout, fmt, vl ); printf("\n"); } va_end(vl); } int …
2010-05-03 17:52 · c program
static *GetSingletonInstance
to release the source code: 1. Box.h #ifndef BOX_H #define BOX_H using namespace std; class Box { protected: int fMax; static Box* pfSingletonInstance; public: Box(int max); ~Box(); public: void setMax(int i); int getMax(void) const ; static Box* GetSingletonInstance(void); }; #endif 2. Box.cpp #in…
2010-04-21 16:06 · c program
c/cp++ - int main()
c/c++ main() 是 c/c++ 开发遇到的第一个问题 同时也不是很简单东西 所以今天查点资料 与大家分享 1. 仅2种形态的main()被接受 即: int main() int main(int argc, char *argv[]) 2. 以一个简单例子演示之 * 代码:接受参数 并打印之 include <iostream> using namespace std; int main(int argc, char *argv[]){ printf("count:%i\n",argc); for(int i=0;i<argc;i++){ cout<<i<<":"<<argv[i…
2010-04-21 11:51 · c program · C · C++ · GCC · C#
makefile 通用
makefile 通用 1. 文件: makefile SRCS = $(wildcard *.c) OBJS = $(SRCS:.c = .o) CC = gcc CCFLAGS = -g -Wall -O0 INCLUDES = -I/home hello : $(OBJS) $(CC) $^ -o $@ $(INCLUDES) $(LIBS) %.o : %.c $(CC) -c $< $(CCFLAGS) clean: rm -f *.o 2. 以下逐行解释: * SRCS = $(wildcard *.c) 列举路径下所有以*.c结尾的文件列表 并存入SRCS * OBJS = $…
2010-04-19 11:08 · c program · C · C++ · GCC · C# · F#
c/cpp programming @ Cygwin
to programming @ Cygwin 1. to install Cygwin - to select the mirror websit : http://www.cygwin.cn/pub/ - to select the following component: binutils gcc gcc-mingw gdb make 2. to verify Cygwin installation is OK? by "Helloworld" - to release source code , compile & run it: #include <stdio.h> int mai…
2010-04-18 18:15 · c program · C · C++ · GCC · C#