Anindya1989 Posted April 18, 2012 Report Posted April 18, 2012 Ok dude see The program i wrote with gotoxy has no bracets eror as u can copy the program and paste as it is in turbo C it will work w/o any error.And isn't there any alternate available orientation is an imp thing in program And we can't orientate programs w/o it..+ We can't give border to things w/o it too(most probly). Then why are you declaring the student structure and taking inputs from gotoxy() function? Isolate gotoxy() first. And sleep worked dude with capital S but another doubt is it said we should use int main rather than void main it worked with int main() but why?The function should not return a value i think.And if yes too than its than returning integer value only If we somehow included char data type too than how it will return values when its clearly written to return a integer value? You program will work for both int main and void main. When you use int main and not return any value the program will automatically return 0 for normal program termination and 1 for abnormal program termination. Quote
CrackUC Posted April 18, 2012 Author Report Posted April 18, 2012 Then why are you declaring the student structure and taking inputs from gotoxy() function? Isolate gotoxy() first. You program will work for both int main and void main. When you use int main and not return any value the program will automatically return 0 for normal program termination and 1 for abnormal program termination. dude that gotoxy function will orientate the result not its taking result..! And by isolating what u meant?Please make a little program of + - etc and orientate the result in middle of screen using gotoxy than only i'll understood what exacly u wanna say.! Quote
Anindya1989 Posted April 18, 2012 Report Posted April 18, 2012 dude that gotoxy function will orientate the result not its taking result..! And by isolating what u meant?Please make a little program of + - etc and orientate the result in middle of screen using gotoxy than only i'll understood what exacly u wanna say.! I never said you are taking the result. I just said why are you taking input like "Enter class name" etc in the function? The gotoxy function should only move the cursor to a desired location on the screen and not anything else. To orient the result you should write your code in a separate function. Your function should exactly do whatever you name it and not anything apart from it. I just came home from office a while back so i'm not in a mood to write a new program right now but i'm restructuring your existing code. Compile it and tell me if it runs. #include <stdio.h> #include <windows.h> typedef struct student { char name[999]; int marks,rollno; }; void gotoxy(int, int); void result(student, student); void gotoxy(int x, int y) { COORD ord; ord.X = x; ord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), ord); } void result(student pehla, student dusra) { int i; char ch=219; printf("\n Here's summary what you have just entered:- "); for(i=22; i<=53; i++) { gotoxy(i,18); printf("%c",ch); Sleep(100); } for(i=18; i<=23; i++) { gotoxy(53,i); printf("%c",ch); Sleep(100); } for(i=53; i>=22; i--) { gotoxy(i,23); printf("%c",ch); Sleep(100); } for(i=23; i>=18; i--) { gotoxy(22,i); printf("%c",ch); Sleep(100); } gotoxy(25,19); printf("name"); gotoxy(35,19); printf("rollno"); gotoxy(45,19); printf("marks"); gotoxy(25,20); printf("%s",pehla.name); gotoxy(35,20); printf("%d",pehla.marks); gotoxy(45,20); printf("%d",pehla.rollno); gotoxy(25,21); printf("%s",dusra.name); gotoxy(35,21); printf("%d",dusra.marks); gotoxy(45,21); printf("%d",dusra.rollno); } void main() { struct student pehla,dusra; system("cls"); printf("\n Enter name class and roll no. of first student"); scanf("%s%d%d",&pehla.name,&pehla.marks,&pehla.rollno); printf("\n Enter name class and roll no. of second student"); scanf("%s%d%d",&dusra.name,&dusra.marks,&dusra.rollno); result(pehla,dusra); system("pause"); } I haven't compiled this. Let me know if it runs. Quote
CrackUC Posted April 18, 2012 Author Report Posted April 18, 2012 I never said you are taking the result. I just said why are you taking input like "Enter class name" etc in the function? The gotoxy function should only move the cursor to a desired location on the screen and not anything else. To orient the result you should write your code in a separate function. Your function should exactly do whatever you name it and not anything apart from it. I just came home from office a while back so i'm not in a mood to write a new program right now but i'm restructuring your existing code. Compile it and tell me if it runs. #include <stdio.h> #include <windows.h> typedef struct student { char name[999]; int marks,rollno; }; void gotoxy(int, int); void result(student, student); void gotoxy(int x, int y) { COORD ord; ord.X = x; ord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), ord); } void result(student pehla, student dusra) { int i; char ch=219; printf("\n Here's summary what you have just entered:- "); for(i=22; i<=53; i++) { gotoxy(i,18); printf("%c",ch); Sleep(100); } for(i=18; i<=23; i++) { gotoxy(53,i); printf("%c",ch); Sleep(100); } for(i=53; i>=22; i--) { gotoxy(i,23); printf("%c",ch); Sleep(100); } for(i=23; i>=18; i--) { gotoxy(22,i); printf("%c",ch); Sleep(100); } gotoxy(25,19); printf("name"); gotoxy(35,19); printf("rollno"); gotoxy(45,19); printf("marks"); gotoxy(25,20); printf("%s",pehla.name); gotoxy(35,20); printf("%d",pehla.marks); gotoxy(45,20); printf("%d",pehla.rollno); gotoxy(25,21); printf("%s",dusra.name); gotoxy(35,21); printf("%d",dusra.marks); gotoxy(45,21); printf("%d",dusra.rollno); } void main() { struct student pehla,dusra; system("cls"); printf("\n Enter name class and roll no. of first student"); scanf("%s%d%d",&pehla.name,&pehla.marks,&pehla.rollno); printf("\n Enter name class and roll no. of second student"); scanf("%s%d%d",&dusra.name,&dusra.marks,&dusra.rollno); result(pehla,dusra); system("pause"); } I haven't compiled this. Let me know if it runs.dude thanks a lot it wrked just it gave a warning that 2 nd main should be int main..! thanks a lot.! +1 dude u Rocked up again...!!!! Quote
Anindya1989 Posted April 18, 2012 Report Posted April 18, 2012 dude thanks a lot it wrked just it gave a warning that 2 nd main should be int main..! thanks a lot.! +1 dude u Rocked up again...!!!! Where did you get 2 main functions? I only wrote one ! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.