A. c語言指針訪問沖突的問題,小程序就教,感謝,程序如下:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct EsgBufferQ {
unsigned char mData[128];
unsigned long length;
}hEsgBuffer;
typedef hEsgBuffer* PEsgBuffer;
typedef struct FreqPoint {
int iFreqId;
PEsgBuffer iEsgBuffer;
}hFreqPoint;
typedef hFreqPoint* PFreqPoint;
int main() {
int i = 0;
PFreqPoint tempFreqPoint;
tempFreqPoint = (PFreqPoint)malloc(sizeof(hFreqPoint)*100); // int 換為 hFreqPoint
tempFreqPoint->iEsgBuffer = (PEsgBuffer)malloc(sizeof(hEsgBuffer)); // 還需為iEsgBuffer申請空間
tempFreqPoint->iEsgBuffer->length = 0;
getchar();
return 1;
}
B. 關於C語言定義掩碼
1、比如定義一個數
int a=0x1111
(unsigned int male=0x4)那麼 a|male 的值就是0001 0001 00010101 只有第三位影響了
unsigned int male=0xFF 那麼 a|male 的值就是111111111 0001 0001 後8位值不變
2、常式:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#defineMAX_PASSWD_LEN20
char*GetPasswd(charpasw[]){
unsignedcharch;
inti=0;
while((ch=_getch())!=' '){
if(i>0&&ch==''){
--i;
putchar('');
putchar('');
putchar('');
}
elseif(i<MAX_PASSWD_LEN&&isprint(ch)){
pasw[i++]=ch;
putchar('*');
}
}
putchar(' ');
pasw[i]='