Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,198 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,344 people online right now. Registration is fast and FREE... Join Now!




debug me

 
Reply to this topicStart new topic

debug me, errors

ms.julie
6 Jul, 2008 - 05:12 PM
Post #1

New D.I.C Head
*

Joined: 6 Jul, 2008
Posts: 1

CODE

#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<graphics.h>
#define MAX 100
struct profile{

char mayari[20];
char plaka[13];
char modelo[30];

}record[MAX];

void view();
void box(int startx, int starty, int endx, int endy, int color);

void main()
{
main:
clrscr();
int driver, mode;
driver=VGA;
mode=VGAMED;
initgraph(&driver,&mode,"");

box(80, 20, 570, 320, GREEN);
box(450, 55, 200, 70, BLUE);

char choice;
char xo;

outtextxy(220,60," \t PROTOCOL'S AUTOMOBILE \t");
setcolor(RED);
outtextxy(170,120,"[R] - Registration");
outtextxy(170,140,"[S] - Search");
outtextxy(170,160,"[E] - Exit");

setcolor(YELLOW);
outtextxy(135,284,"  >>Enter your choice: ");
gotoxy(43,21);
choice=getche();

switch(choice)
{
case 'R':
{goto lagay; }
case 'V':
{goto view; }
case 'E':
{getch(); }
default:
{main(); }
}
lagay:
int bilangCount;
int optxn;
int watawat;
int reNum = 10;
char sNgalan[20];

static struct profile student[10];
clrscr();
bilangCount = 1;
outtextxy(170,1,"\t R E G I S T R A T I O N \t");
for(bilangCount=1; bilangCount <= reNum; bilangCount++)
{
printf("\nEntry Number %d", bilangCount);
printf("\n\nPlate No.:\n ");
gets(student[bilangCount].plaka);
printf("\n\nOwner's Name: \n");
gets(student[bilangCount].mayari);
printf("\n\nAutomobile Model: \n");
gets(student[bilangCount].modelo);
clrscr();
}

for(bilangCount=1; bilangCount <= reNum; bilangCount++)
{
printf("\nEntry Number %d", bilangCount);
printf("\n\nPlate Number: %s", student[bilangCount].plaka);
printf("\nOwner's Name: %s", student[bilangCount].mayari);
printf("\nAutomobile Model: %s", student[bilangCount].modelo);
}
printf("\nPress any key to continue...");
getch();


retry:
clrscr();

printf("\nWhat would you like to do???");
printf("\n\n1 - Search");
printf("\n2 - Exit");
scanf("%d",&optxn);

if(optxn == 1)
{
clrscr();
printf("\nEnter Keyword: ");
scanf("%s",&sNgalan);
watawat = 1;
clrscr();

printf("\nRESULT BELOW: ");
for(bilangCount = 1; bilangCount <= reNum; bilangCount++)
{

if(strcmp(sNgalan,student[bilangCount].plaka) == 0)
{
watawat = 2;

printf("\nResult found in Entry No. %d",bilangCount);
printf(": Plate Number");

}

if(strcmp(sNgalan,student[bilangCount].mayari) == 0)
{
watawat = 2;

printf("\nResult found in Entry No. %d",bilangCount);
printf(": Owner's Name");
}

if(strcmp(sNgalan,student[bilangCount].modelo) == 0)
{
watawat = 2;

printf("\nResult found in Entry No. %d",bilangCount);
printf(": Automobile Model");

}
printf("\n\n\n\nPress any key to continue...");
getch();
goto retry;
}

if(watawat == 1)
{
printf("\n\nKeyword not found!");
printf("\n\n\n\nPress any key to continue...");
getch();
goto retry;
}
}

if(optxn == 2)
{
return;
}
if((optxn != 1) && (optxn != 2))
{
goto retry;
}
getch();
}

void view()
{
static struct profile student[10];
int bilangCount, reNum;
for(bilangCount=1; bilangCount <= reNum; bilangCount++)
{

printf("\nEntry Number %d", bilangCount);
printf("\n\nPlate Number: %s", student[bilangCount].plaka);
printf("\nOwner's Name: %s", student[bilangCount].mayari);
printf("\nAutomobile Model: %s", student[bilangCount].modelo);
}
printf("\nPress any key to continue...");
getch();
}



void box(int startx, int starty, int endx, int endy, int color)
{
setcolor(color);
line(startx, starty, startx, endy);
line(startx, starty, endx, starty);
line(endx, starty, endx, endy);
line(endx, endy, startx, endy);
}

User is offlineProfile CardPM
+Quote Post

KYA
RE: Debug Me
7 Jul, 2008 - 06:36 AM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 5,049



Thanked: 124 times
Dream Kudos: 1200
My Contributions
You aren't going to get too many good responses since you did not state any problems you are having, any specific errors, and what is the point of your code/project. People generally do not like digging through code without an idea of what to look for and/or do.
User is online!Profile CardPM
+Quote Post

captainhampton
RE: Debug Me
7 Jul, 2008 - 11:17 AM
Post #3

Jawsome++;
Group Icon

Joined: 17 Oct, 2007
Posts: 518



Thanked: 2 times
Dream Kudos: 825
My Contributions
Maybe you could start by listing the problems in particular you have had with this code, errors generated by your compiler, etc.
User is offlineProfile CardPM
+Quote Post

Einherjar
RE: Debug Me
7 Jul, 2008 - 12:28 PM
Post #4

D.I.C Head
**

Joined: 10 Feb, 2008
Posts: 73


My Contributions
Something I did notice right away. Don't use goto statements at all. Accomplish the same thing with loops.
User is offlineProfile CardPM
+Quote Post

Delta_Echo
RE: Debug Me
7 Jul, 2008 - 08:06 PM
Post #5

D.I.C Regular
***

Joined: 24 Oct, 2007
Posts: 439


My Contributions
1. Its just rude and lazy to throw code in a post and not explain the problem or the intent. We are not code rats, get someone else to drudge through your code.
2. Avoid GOTO. Its too static.

Good Luck
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 12:14PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month