CANNOT RUN!!!!! any idea why? ANSI-C

T

toch3

im making a new ANSI-C program Address Book...by myself but cannot
run...i cant figure out why...im newbie in programming..could anyone
correct the coding for me...plz..

***************************************************************************************************
Write the program in
ANSI-C, using the libraries that you have learnt. Below is a list of
libraries
that you are allowed to use:
· stdio.h
· stdlib.h
· string.h
· math.h
· time.h

Simple Contact Book
Write a program that is capable of acting as a simple contact book. The
range of
functions that this simple contact book should have includes:
· Adding contacts
· Deleting contacts
· Searching contacts (based on name)
· Edit contacts
· Listing contacts (sorted in alphabetical order based on name)
All the contacts must be saved into a file, which can be retrieved and
update by the
program.
Below is the information is the contact book is required to store:
· Name
· Birthday
· Hand phone number
· Address
*********************************************************************************************************


#include<stdio.h>
#inlcude<stdlib.h>
static int cno

typedef char *string; //renaming type char as string
typedef struct //renaming sturcture as students
{

string first_name[50]:; //can also be string *first name
string last_name[50]:;
int age;
string ssn;
char gender;
string phone_number[20];
string address[100];
}contacts; //type students
contacts ininfo(void); //function in program
contacts modify(void);
contacts delete(void);
contacts search(void);



const int size=60; //in program student student_record
void main()
{
int choice;
contact c[100];
contact tmp;
puts("1) Enter new contact information and save to disk");
puts("2) Modify a record");
puts("3) delete information");
puts("4) Print list");
puts("5) Search");
puts("6) Exit");
puts("Please make a choice");
scanf("%i",&choice);
switch(choice)
{
case 1:
c[cno++]=tmp.ininfo();
break;
case 2:
c[cno++]=tmp.modify();
break;
case 3:
contacts tp;
int cono;
puts("contact number:\n");
scanf("%d",&cono);

c[cono]=tmp.delete();
break;
case 4:
for(i=0;i<cno;i++)
{
printf("%s /n %s /n %d /n %s /n %s /n
%s",c.first_name,c.last_name,c.age,c.gender,c.phone_number,c.address;
}
break;
}


}
contacts ininfo(void)
{
contacts temp;
puts("first name:\n");
scanf("%s",temp.first_name);
puts("last name:\n");
scanf("%s",temp.last_name);
puts("age:\n");
scanf("%i",&temp.age);
puts("gender: (M or F)");
scanf("%s", temp.gender);
puts("SSN:\n");
scanf("%s", temp.ssn);
puts("Phone number:\n");
scanf("%s",temp.phone_number);
puts("Address:\n");
scanf("%s", temp.address);
return temp;
}

contacts modify(void)
{
contacts temp;
int conno;
puts("contact number:\n");
scanf("%d",&conno);

for(i=0;i<cno;i++)
{
if(conno==i)
{
scanf("%s",temp.first_name);
puts("last name:\n");
scanf("%s"temp.last_name);
puts("age:\n");
scanf("%i",&temp.age);
puts("gender: (M or F)");
scanf("%s", temp.gender);
puts("SSN:\n");
scanf("%s", temp.ssn);
puts("Phone number:\n");
scanf("%s",temp.phone number);
puts("Address:\n");
scanf("%s", temp.address);
return temp;
}
}
}

contacts delete(void)
{
contacts temp;
int conno;
puts("contact number:\n");
scanf("%d",&conno);

for(i=0;i<cno;i++)
{
if(conno==i)
{
temp.first_name="";
temp.last_name="";
temp.gender="";
temp.phone number="";
temp.address="";

}
}

}

contacts search();
{

contacts temp;
string fn;
puts("first name:\n");
scanf("%s",fn);

for(i=0;i<cno;i++)
{
if(fn=temp.first_name)
{
printf("%s /n %s /n %d /n %s /n %s /n
%s",c.first_name,c.last_name,c.age,c.gender,c.phone_number,c.address;
}
}
}
*******************************************************************************************************
plz help tq
 
D

Default User

toch3 said:
im making a new ANSI-C program Address Book


How many times are you planning on posting this?





Brian (thinking uncharitable thoughts at present)
 
B

Barry Schwarz

im making a new ANSI-C program Address Book...by myself but cannot
run...i cant figure out why...im newbie in programming..could anyone
correct the coding for me...plz..

snip redundant code already posted in "Help me/...."

This isn't instant messaging. Wait for your first message to
propagate. It already has some responses. Correct those problems.

Don't change the subject. Keep all the messages in a single thread.

Don't SHOUT. Many will not bother if you appear impolite or
demanding.


Remove del for email
 
O

Old Wolf

toch3 said:
im making a new ANSI-C program Address Book...by myself but cannot
run...i cant figure out why...im newbie in programming..could anyone
correct the coding for me...plz..
plz help tq

Your code contains a lot of syntax errors. Your compiler will
write out an error message for each of them, that you can use
to fix it.

Once you have got a program that compiles without error,
post it, and people will be able to help you with why it
doesn't work.

Also, please try to type properly; people are more likely to
reply to a message that they can read easily.
 
B

Bill Pursell

toch3 said:
im so sorry...im a newbie here...what should i do....delete then make
new wan?

First: Do retain some attributions in your post.
2nd: don't top -post ( Thats' weak humor: if
there are no attributions at all then it's a philosophical
question whether you've placed the (empty) text
before or after your own.)
3rd: Address the problems in the code that are raised
by the compiler.
4th: Address the problems in the code that are addressed
by other posts.
5th: Do not send email to people with this same question!!
 
O

osmium

toch3 said:
im so sorry...im a newbie here...what should i do....delete then make
new wan?

No, don't delete, whether a delete is complied with is at the discretion of
the newsgroup server. You should have chosen a descriptive name and used it
until your problems were solved or you gave up in disgust. Now you have
*three* thread which anyone trying to help you must dig through and follow.
It is too late to do the right thing now, you will just have to muddle
through.

This creates huge problems. In thread 1 you say to use global array, the
instructor made it easy on you when he did this. But in thread 2 you use a
non-global array - c is defined in main. How can anyone properly point that
out to you now? Usenet is based on a single thread for a series of related
things.

You seem to ignore most of the advice you were given. Someone mentioned
excess colons and I still see excess colons. You pretty much ignored my
advice. I think you would make better progress if you pretend the keyword
"typedef" did not exist in the language.

You seem to be trying for extra credit by adding stuff to the data, such as
ssn, that the instructor didn't even ask for. Get the damned thing working,
*then* add frosting and ribbons and bows. Two elements in a structure are
sufficient to show that it is indeed functioning as a structure and not
something else. To have five elements just results in an orgy of typing.
Your course is not intended to improve typing skills.

Can you not see what I meant when I talked about inconsistency? It is still
there.

Try removing all usage of "typedef".

Get rid of the excess data fields.

Repost in one of the three threads you have started, I suggest continuing
the first one.
 
T

toch3

im so sorry...i post so many times this prog..but go flame by many
ppl...im new here...and new in programming...i took/applied the source
code directly from texts book...yes i can understand what u
fixing...but i dun know how to apply it to my program...could u
recorrect the code by replacing the error that i make...im so sorry..
 
M

Michael Mair

toch3 said:
im so sorry...i post so many times this prog..but go flame by many
ppl...im new here...and new in programming...i took/applied the source
code directly from texts book...yes i can understand what u
fixing...but i dun know how to apply it to my program...could u
recorrect the code by replacing the error that i make...im so sorry..

Nobody is flaming you -- yet.
Just follow the advice you have been given: Turn up the warning
level of your compiler and work methodically through the warning
and error messages it gives you.
If you encounter one you do not understand, then come back and
ask. As soon as you have fixed everything your compiler complains
about (be it with or without help), then repost your corrected
version if it still does not do what you expect it to do.
Explain what you expect and what happened.

Please try to do so in coherent English, without recurse to
abbreviations like "u" and "ppl" -- they just make people who
could help you ignore your messages. There are many non-native
speakers here, me among them, and it is perfectly acceptable that
they do not write in the best possible English -- but there is a
difference between honest mistakes and "lazy" abbreviations,
especially if the latter make it unnecessarily hard to read a
technical question which may be fraught with other problems and
subtle points as well.


Cheers
Michael
 
T

toch3

Im so sorry guys..thanks for the instruction...i'll use the 1st post i
make...plz ignore this thread and move to the Help me/ thread...really
sorry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top