#include stdio.h
公司主營業(yè)務(wù):做網(wǎng)站、網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出競秀免費(fèi)做網(wǎng)站回饋大家。
#define SIZE 255+1 /*假設(shè)字符串最長為255個(gè)字節(jié)*/
void main()
{
void analyze(char *test);
char test[SIZE];
gets(test);
analyze(test);
};
void analyze(char *test)
{
int i=0;
int word=0, /*字母個(gè)數(shù)*/
num=0, /*數(shù)字個(gè)數(shù)*/
space=0, /*空格個(gè)數(shù)*/
other=0; /*其它字符個(gè)數(shù)*/
while(test[i]!='\0')
{
/*以下數(shù)字可查ASCII表得到*/
if(test[i]==32) /*空格*/
space++;
else if(test[i]=48test[i]=57)/*數(shù)字*/
num++;
else if((test[i]=65test[i]=90)||(test[i]=97test[i]=122))/*字母*/
word++;
else/*其它*/
other++;
i++;
}
printf("%d words\n",word);
printf("%d numbers\n",num);
printf("%d spaces\n",space);
printf("%d other words\n",other);
}
你在棧中使用了過多空間(例如開辟了超大數(shù)組)。將占用過多空間的變量移到全局區(qū)或者使用malloc為其在堆中分配內(nèi)存。
#include
#include
char format[]="%s%s\n";
char hello[]="Hello";
char world[]="world";
HWND hwnd;void main(void)
asm
//push NULL
//call dword ptr GetModuleHandle
//mov hwnd,eax push MB_OK mov eax,offset world push eax mov eax,offset hello push eax push 0//說明此處不能將前面注釋掉代碼處得到的hwnd壓棧,否則對話框彈不出來。
call dword ptr MessageBox
}
}
WINDOWS程序MessagBox
WINDOWS或控制臺 assert
C/C++ code
// crt_assert.c
// compile with: /c
#include stdio.h
#include assert.h
#include string.h
void analyze_string( char *string );?? // Prototype
int main( void )
{
char? test1[] = "abc", *test2 = NULL, test3[] = "";
printf ( "Analyzing string '%s'\n", test1 ); fflush( stdout );
analyze_string( test1 );
printf ( "Analyzing string '%s'\n", test2 ); fflush( stdout );
analyze_string( test2 );
printf ( "Analyzing string '%s'\n", test3 ); fflush( stdout );
analyze_string( test3 );
}
// Tests a string to see if it is NULL,
// empty, or longer than 0 characters.
void analyze_string( char * string )
{
assert( string != NULL );??????? // Cannot be NULL
assert( *string != '\0' );?????? // Cannot be empty
assert( strlen( string ) 2 );? // Length must exceed 2
}
擴(kuò)展資料:
#include windows.h
#include Commdlg.h
#include stdio.h
// 返回值: 成功 1, 失敗 0
// 通過 path 返回獲取的路徑
int FileDialog(char *path)
{
OPENFILENAME ofn;
ZeroMemory(ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // 結(jié)構(gòu)大小
ofn.lpstrFile = path; // 路徑
ofn.nMaxFile = MAX_PATH; // 路徑大小
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"; // 文件類型
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
return GetOpenFileName(ofn);
}
int main(char argc, char *argv[])
{
char szFile[MAX_PATH] = {0};
if(FileDialog(szFile))
{
puts(szFile);
}
getchar();
return 0;
}
下面是我寫的分解質(zhì)因數(shù)的程序,你參考一下
#include stdio.h
#include math.h
void analyze(int n)
{
int a[20];
int count = 0;
int i;
int number = n;
while(1)
{
for(i = 2; i (int)sqrt(n); i++)
{
if(number % i == 0)
{
a[count] = i;
count++;
number = number / i;
break;
}
}
if(number == 1)
{
break;
}
}
printf("%d = ", n);
for(i = 0; i count; i++)
{
printf("%d * ", a[i]);
}
printf("\b\b");
}
void main()
{
int number;
printf("please input a number: ");
scanf("%d", number);
analyze(number);
}
名稱欄目:analyze函數(shù)c語言 c語言alarm函數(shù)
轉(zhuǎn)載源于:http://muchs.cn/article30/doeespo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、云服務(wù)器、網(wǎng)站改版、品牌網(wǎng)站制作、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)