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]='