[問題] 關於引數資料型態問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev c++
用C語言寫
問題(Question)
想請問大家,有沒有什麼方法
使memoryClean的傳入引數可以接受任何資料型態阿?
多謝指教
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <stdio.h>
#include <stdlib.h>
#define STRING_SIZE 10
char string[ STRING_SIZE ] = "EXAMPLE";
void memoryClean( char *);
int main(void)
{
printf( "Before clean the memory of string, the content of string is %s\n\n" , string );
memoryClean( string );
printf( "After clean this memory , the content of string is %s\n\n" , string );
system( "pause" );
}
void memoryClean(char *memoryAddress )
{
int i = 1;
for ( i = 1 ; i< STRING_SIZE ; i++ ){
*memoryAddress = 0;
memoryAddress++;
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.233.180.163
→
01/26 21:41, , 1F
01/26 21:41, 1F
→
01/26 21:41, , 2F
01/26 21:41, 2F
→
01/26 21:44, , 3F
01/26 21:44, 3F
→
01/26 21:50, , 4F
01/26 21:50, 4F
→
01/26 21:53, , 5F
01/26 21:53, 5F
→
01/26 22:02, , 6F
01/26 22:02, 6F
→
01/26 22:19, , 7F
01/26 22:19, 7F
→
02/07 11:32, , 8F
02/07 11:32, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章