c언어질문.
냐하
질문 제목 : 질문 내용 :
#includestdio.h
#includetime.h
#includewindows.h
void color(unsigned short color);
void gotoxy(int x, int y);
void cursorview(char show);
void randomlotto(int *arr);
void showlottonum(int* arr);
void cornumber(int* arr1,int *arr2);
struct buyer{
char* buyername;
int* buylottonum;
int cornum;
void infobuyer(){
printf(구매자이름을 입력하세요:);
scanf(%s,&buyername);
printf(로또번호를 입력하세요:);
for(int i=0;i7;i++){
scanf(%d,&buylottonum);
}
}
};
struct buyer buy={0,0,0};
int main(void){
buy.infobuyer();
int* array; //정답
srand(time(null)); // 초기화.
array=(int*)malloc(sizeof(int)*6);
randomlotto(array);
showlottonum(array);
cornumber(buy.buylottonum,array);
getchar();
return 0;
}
void cornumber(int* arr1,int* arr2){
for(int i=0;i7;i++){
for(int j=0;j7;j++){
if(arr1[i]==arr2[j])
buy.cornum++;
}
}
printf(맞은갯수는 %d,&buy.cornum);
}
void color(unsigned short color)
{
handle hcon = getstdhandle(std_output_handle);
setconsoletextattribute(hcon,color);
}
void gotoxy(int x, int y)
{
coord pos = {x - 1, y - 1};
setconsolecursorposition(getstdhandle(std_output_handle), pos);
}
void cursorview(char show) //커서 숨기기, 보이기(0, 1)
{
handle hconsole;
console_cursor_info consolecursor;
hconsole = getstdhandle(std_output_handle);
consolecursor.bvisible = show;
consolecursor.dwsize = 1;
setconsolecursorinfo(hconsole , &consolecursor);
}
void randomlotto(int *array){
for(int i=0;i7;i++){
array[i]=rand()%45 +1;
for(int j=0;ji;j++){
if(array[i]==array[j])
i--;
}
}
}
void showlottonum(int* arr){
for(int r=0;r7;r++){
if(r6){
printf(%d ,arr[r]);
}
else if(r==6){
color(13);
printf(보너스번호추첨:);
printf(%d,arr[r]);
color(7);
}
}
}
실행은되는데 로또번호를 show해준다음에 에러가 뜨면서 꺼져버리네요.
아마 빨갛게 표시되는 부분이 에러인거같은데 무엇이 문제인지를 모르겠네요
-
키움
BuyLottoNum문이 포인터로만 선언 되어 있습니다. 배열로 만들어 입력 부분 수정 하시면 될것 같습니다.
그리고 솔직히 말해 디버거도 모든 사람이 비쥬얼 스튜디오를 사용하는건 아니니 따로 만들어서 관리 해 보면 됩니다.
#define VERBOSE 1
#define LOG(x) do { if (VERBOSE) printf x; } while (0)
위에 위 문장 적어 놓으시고 알고 싶은 부분에
LOG((\debug BuyLottoNum -
단순드립
에러가 뜬다고 하셨는데, 에러 메시지 내용이 무엇인지요?
실행중에 에러 나는 것은 디버거를 이용해서, 실행하면서 값을 확인해보는 수 밖에는 없습니다.