Solved

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

Posted on 1998-10-30
23
198 Views
Last Modified: 2010-04-15
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 !!!!!!!
0
Comment
Question by:naturalmystic
  • 11
  • 8
  • 2
  • +2
23 Comments
 

Expert Comment

by:the_shrink
ID: 1253915
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
 

Author Comment

by:naturalmystic
ID: 1253916
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
 
LVL 1

Accepted Solution

by:
cssathya earned 100 total points
ID: 1253917
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253918
Maybe if you stop shouting someone will help you :)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1253919
:)
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253920
Hey whassup Vik!!
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1253921
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253922
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253923
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1253924
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253925
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 10

Expert Comment

by:viktornet
ID: 1253926
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253927
So how 'bout them Bears???
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1253928
What's w/ da Bears??? What's ya talkin' 'bout??

Vik
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253929
Da Bearss.  Not da Bullss.  Da Bearss.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1253930
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253931
Da Bearss.  :)

You is in Chicago, isn't ya?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1253932
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253933
Vik, you must be a dyslexic philosopher who is spending his whole life wondering whether or not there really is a DOG...

:)
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253934
It is 3:35!  Go to bed, you are a growing boy :)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1253935
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1253936
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
 

Author Comment

by:naturalmystic
ID: 1253937
YEA I CAN WORK WITH THIS.
     THANKS!
           MYSTIC.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now