出現下列錯誤訊息時,只要在gcc compiler加上後面的 -lm 即可解決。
Rwh_FilterModule.c:(.text+0x1412): undefined reference to `sqrt'
Rwh_FilterModule.c:(.text+0x1430): undefined reference to `cos'
Rwh_FilterModule.c:(.text+0x144a): undefined reference to `sqrt'
Rwh_FilterModule.c:(.text+0x1468): undefined reference to `sin'
Rwh_FilterModule.c:(.text+0x16d4): undefined reference to `cos'
Rwh_FilterModule.c:(.text+0x1718): undefined reference to `cos'

S 發表在 痞客邦 留言(0) 人氣()

1
使用fgets()常會遇到一個問題,輸入的字元數目超過Buffer給定的,就會出現下列的狀況。
狀況:當程式為 fgets( cName, 30, stdin ); 時,輸入超過30 個字元,程式就會每次輸出30個字元直到全部資料被輸出。下列為此種現象程式碼及狀況示意圖 :
#include <stdio.h>
#include <string.h>
int main()
{
char cName[30];
FILE *pFile;

pFile = fopen( "write.csv", "a" );
if( pFile == NULL )
{
printf("open failure");
return 1;
}
while(1)
{
printf("please enter your name: \n");
fgets( cName, 30, stdin );
if( 'E' == cName[0] && ('\n' == cName[1] || '\0' == cName[1] ))
{
break;
}

fwrite(cName, 1, strlen( cName ) , pFile);
memset( cName, 0x00, sizeof( cName ) );

}
fclose(pFile);
return 0;
}

S 發表在 痞客邦 留言(0) 人氣()

2
gets() 取得使用者輸入的全部字串,包括空白字元。
char * gets ( char * str );
scanf() 取得使用者輸入的字串,遇到空白字元就停止取得。
int scanf ( const char * format, ... );

S 發表在 痞客邦 留言(0) 人氣()

blog01
printf()之使用功能為將指定的文字、數字等等...顯示在螢幕上,使用此函數必須先#include <stdio.h>
小試身手小範例(1)
#include <stdio.h>
int main(void)
{
    printf("Innovation distinguishes between a leader and a follower \n");
    printf("by Steven Jobs \n");
}

S 發表在 痞客邦 留言(0) 人氣()

1
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。