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 -
단순드립
에러가 뜬다고 하셨는데, 에러 메시지 내용이 무엇인지요?
실행중에 에러 나는 것은 디버거를 이용해서, 실행하면서 값을 확인해보는 수 밖에는 없습니다.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695270 | 질문이요..swap 관한겁니다..ㅠㅠ (3) | 콩알녀 | 2025-05-19 |
2695244 | 노땅초보궁금한게 하나 있는데요..반복문(while문)초보자질문 (6) | 큰꽃늘 | 2025-05-18 |
2695166 | do while 문 어떤것이잘못된건지 모르겠어요 (2) | 아이폰 | 2025-05-18 |
2695122 | 구조체에 대해 물어보고 싶은게 있습니다 ^^^.. (7) | 수련 | 2025-05-17 |
2695091 | txt 파일 입출력 후 2차 배열에 저장하기입니다. (3) | 헛장사 | 2025-05-17 |
2695063 | 수도요금 프로그램좀 짜주세요. | 시내 | 2025-05-17 |
2695033 | 답변좀요ㅠㅠ (1) | 비사벌 | 2025-05-16 |
2695010 | C++의 STL은 왜 굳이 템플릿화 시켜서 라이브러리를 만드나요? (초보수준의 질문..) (2) | 엘보어 | 2025-05-16 |
2694958 | 로직이 변한다는 것에 대해서 궁금합니다. | 튼동 | 2025-05-16 |
2694929 | 열혈강의 25-2 두번째 문제 질문 | 지우개 | 2025-05-15 |
2694900 | dequeue 에서 리턴값 프린트 방법알려주세요 오늘 12시까지 대화방에 있습니다 도와주세요 | 미투리 | 2025-05-15 |
2694854 | 절대값을 구할때 (2) | 그녀는귀여웠다 | 2025-05-15 |
2694827 | 이제 어떻게 공부해야할지 모르겠네요 | 새얀 | 2025-05-14 |
2694778 | 순열 계산요. | 맛조이 | 2025-05-14 |
2694754 | ShowWindow 함수를 이용하려 하는데 질문있습니다. (2) | 파도 | 2025-05-14 |
2694731 | 리눅스 커널의 시작점 질문 | 미르 | 2025-05-13 |
2694702 | 이거 뭐가문제인가요 코드수정좀 (3) | 맑은 | 2025-05-13 |
2694675 | C언어 후위표기를 중위표기로 | 앨런 | 2025-05-13 |
2694646 | 안녕하세요 파일 합치기 함수! (1) | 연블루 | 2025-05-13 |
2694618 | 잘몰라서 설명부탁드립니다. scanf 관련 (3) | 파라 | 2025-05-12 |