#include <iostream> #include<stdlib.h> #include <time.h>
srand(time(NULL));//此行每次都加表示每次都會重新刷新
int tenbuf = int((rand() % 10) + 1);//1~10 int hubuf = int((rand() % 100) + 1);//1~100
測試環境 mfc c++空專案
#include <iostream> #include<stdlib.h> #include <time.h>
srand(time(NULL));//此行每次都加表示每次都會重新刷新
int tenbuf = int((rand() % 10) + 1);//1~10 int hubuf = int((rand() % 100) + 1);//1~100
測試環境 mfc c++空專案
int atoi(const char *str)
int val; char str[20]; strcpy(str, "123456"); val = atoi(str); //String value = 123456, Int value = 123456 strcpy(str, ".net"); val = atoi(str); //String value = .net, Int value = 0
測試環境: vs 2015 mfc
FILE* pFile; while (!feof(pFile)) { //fread 讀取 //資料處理 } //如先使用fread讀取,再來判斷feof,當feof判斷為true時就跳離loop while (1) { //fread讀取 if (feof(pFile)) break; }
測試環境 vc 2015 mfc
//在mfc中使用前請先至Stdafx.h 宣告定義
#define _CRT_SECURE_NO_WARNINGS
---------以下為範例--------------------------
FILE *pFile; char cbuffer[] = { 'h','e','l' ,'l' ,'o' }; pFile = fopen("hello.txt", "w"); if (pFile == NULL) { MessageBox(L"empty"); } else { fwrite(cbuffer,1, sizeof(cbuffer), pFile); } fclose(pFile);
測試環境:2015--mfc
參考以下:
FILE * fopen ( const char * filename, const char * mode );
CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CONVERT style參數說明 1 (expression為 money 或 smallmoney型別): 0 : 預設,保留小數位後兩位,並四捨...