• C

how to write a program like........

HELP
     I JUST STARTED  STARTED LEARNING C  (LIKE ABOUT TWO MINUTES AGO).I GOT
AN  ASSIGNMENT IN WHICH  I NEED TO WRITE A PROGRAM THAT IMPLEMENTS A RUDIMENTARY  STUDENT INFORMATION SYSTEM IN WHICH IT ALLOWS THE USER TO INSERT , RETRIEVE, AND DELETE IN THE STUDENT FILE. THE STUDENT ID WOULD BE THE PRIMARY KEY[5BYTES]. THE RECORD SHOULD CONTAIN THE FOLLOWING FIELDS :
STUDENT ID[`5 BYTES] , NAME[ UP TO 25 BYTES] ,TELEPHONE # [12 BYTES], AND MAJOR [UP TO 25 BYTES] . I NEED SEQUENTIAL ACCESS AND BE ABLE TO INSERT RECORDS IN THE POSITION  OF DELETED RECORDS.
IN NEED OF DESPERATE HELP  NOW !!!!!!!
naturalmysticAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
the_shrinkCommented:
here's how :

the equivalent of records in  C is a STRUCTURE .(STRUCT) .this sort of a variable has many elments inside it.Thus when we have say 10 elements which are Structures it means each of these ten elements may have a fixed value of sub-elements.in your case, the students are the structures and their details are the structure elements like name,marks... thus your structure can be defined as

main(){
struct {
char name[20];
int mark;
...
....
} student[20];
now each student's details can be accessed by
  student[ student no. ] . (field)
eg. student[2].mark or student[20].name
these are the regular fundas . if you want more details refer books.Easier in them






0
 
naturalmysticAuthor Commented:
THANKS FOR ANSWERING MY QUESTION SO QUICKLY _SHRINK ,BUT I'M KINDA PRESSED FOR TIME AND SO IDON'T HAVE MUCH TIME TO READ ANY BOOKS RIGHT NOW .I ALSO FAILED TO MENTION BEFORE THAT I'M SUPPOSE TO WRITE THIS THING WITHOUT USING A STRUCT.SO YOUR ANSWER IS NOT REALLY HELPING ME.WHAT I REALLY NEED IS SORT OF AN ALGORITHM OR BASIC OUTLINE THAT I CAN WORK WITH.
0
 
cssathyaCommented:
Well, If u do not want a structure, the nearest thing to a database is a single array. So u have to use arrays for hanndling the data. Have an array for ID, name, telephone # and major. put all the data in the corresponding fields of the array. Then if u want to access them, u can access them using the array index. First, ask the ID. Then llok up in the ID array for the index corresponding to the ID. Using that index, u can access the data from the other arrays, u can access the fields in other arrays.

The program roughly will be like this:

Considering a fixed number of students - say 20.

long int id[20], phone[20];
char name[20][25], course[20][25];

/* getting data */

for(i=0;i<20;i++)
{
  scanf("%d", &id[i]);
  scanf("%s", &name[i]);
  scanf("%s", &major[i]);
  scanf("%d", &phone[i]);
}

/* reading data */

scanf("%d", &gid);

for(i=0;i<20;i++)
 if (gid==id[i])
    index=i;

printf("id=%d name=%s course=%s phone=%d", id[index], name[i], course[i], phone[i]);

Well, this rough sketch will have some problems in the array initialization and string handling but the idea is this. You can also use an array that acts as a linked list that will efficiently insert and delete data. If u do not know about a linked list, u can still use the array. Linked list will be better.

Hope this helps u. All the best.

 




0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
scrapdogCommented:
Maybe if you stop shouting someone will help you :)
0
 
viktornetCommented:
:)
0
 
scrapdogCommented:
Hey whassup Vik!!
0
 
viktornetCommented:
Wuz up man?? Thought you were dead . o O :)

btw- Any updates to the ticky-tak or any other interesting robot stuff??? The time machine?? Anything else that would interest me???

Vik
0
 
scrapdogCommented:
As soon as I get my time machine working, I am going to go back home, to the year 400 billion.

As far as ticky-tac, the only thing I have done is the thing I sent you.  Did you look it over?

Anything else interesting...hmm not really, unless you are interested in a c64 sprite editor!!!
0
 
scrapdogCommented:
By the way Vik, I am experimenting with MDI forms...I have never done it before.  Being the Delphi god you are, I would appreciate some help!!
0
 
viktornetCommented:
What exactly is that that you wanna do with them???

Simply Create two forms.... Set the first one's FormStyle := fsMDIForm; and the other one's FormStyle := fsMDIChild;

That's all... Easy job... So far so good....let's see what actually are your questions :)

Cheers,
Viktor
0
 
scrapdogCommented:
I haven't started yet, but in the near future I am going to experiment with them.  If I have any questions, you will be the one I go to!!

I am working from the bottom up on this project, so it might be awhile before I even start on the forms...
0
 
viktornetCommented:
No problem.... Just to give you an idea how much I know about MDIs. Here is the definition...

Definition: I know as much as you know :) This is suppose to tell you some important info :) I don't know anything... I have never worked with MDIs. Maybe tried it once, and that's all... However, you could still ask me and I'll try to answer your question...

Vik =)

I liked what one of the guys wrote somewhere on a forum...Here it is...

"If GOD can do it, why can't I?"
and GOD immediately answered...
"You can, just watch ME"

Kewl, eh???

=)
0
 
scrapdogCommented:
So how 'bout them Bears???
0
 
viktornetCommented:
What's w/ da Bears??? What's ya talkin' 'bout??

Vik
0
 
scrapdogCommented:
Da Bearss.  Not da Bullss.  Da Bearss.
0
 
viktornetCommented:
I never said anything about Da Bulls?? I still don't know you are talking about... Bears?? Teams?? Animals???? What's the joke w/ that????? Please enlighten me on that one...

Vik
0
 
scrapdogCommented:
Da Bearss.  :)

You is in Chicago, isn't ya?
0
 
viktornetCommented:
Yeah, I are in Chicago... and what's da fun part 'bout da Bears??? Ain't nothing good 'bout 'em... I dislike 'em...

"If GOD can't do it, why can I?"
GOD immediately answers...
"I can't because I'm a DOG" :) DOG -> GOD    DoGGoD

Vik
0
 
scrapdogCommented:
Vik, you must be a dyslexic philosopher who is spending his whole life wondering whether or not there really is a DOG...

:)
0
 
scrapdogCommented:
It is 3:35!  Go to bed, you are a growing boy :)
0
 
viktornetCommented:
Juswt tryin' to have some fAn :)

It's really gett'n kinda late over here... Gotta go to bed... Talk 2 U tomorrow...

btw- i didn;t try the tic-tak since I didn't wanted to go to DOS and use TP7... In order to test that code I need to shut down windows and then go to DOS,,,The run TP and so on... I'm the lazy kind...so when you think you are done with it I'll get some time to see it :)

Do you like "Gettin' Jiggy Wit It" by Will Smith... I like it a lot,. but it ain't hit no more.... There is that "Just crashing on..." by the Joe or whatever his name is... It's a cool one =)

Bye y'all talk 2 y'all L8R

Cheers,
Viktor B-)
0
 
scrapdogCommented:
1.  TP7 runs fine under Windows 95 (at least it does for me...)
2.  Please refer to

http://www.experts-exchange.com/topics/customerservice/lounge/Q.10092713
0
 
naturalmysticAuthor Commented:
YEA I CAN WORK WITH THIS.
     THANKS!
           MYSTIC.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.