Please help me for this.

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

I need an urgent homework help. Please if anyone kows how to make a program please help me. I am not good at computer programming. I am taking this class as a requirements. I would be grateful if someone can help me with this program. Here is the program : You will be making an inventory program. You will have an array of 10 structure pointers. The structure will have a array of 15 characters (for the name) and an int (for the weight). Allow the user to enter items in the inventory (they can decide to have one item or 10 items.) Only allocate memory if the inventory needs it. Have the item placed in the inventory array. When the user is done entering items, print them all out. DO NOT PRINT OUT THE ITEMS UNTIL THEY HAVE ALL BEEN ENTERED! Then free the allocated memory

Udeshya · Feb 22, 2012 10:05 AM · 10,948 views

6 Replies

Which Language ?

Mulmiz · Feb 22, 2012 12:26 PM

 @ mulmiz ... It is in "C". I would appreciate your help.

udeshya · Feb 22, 2012 12:38 PM

Is there anyone around who is good at C or C++ programming. Please guys help me out with this program.

Udeshya · Feb 22, 2012 4:01 PM

Last edited: 22-Feb-12 04:38 PM

serial · Feb 22, 2012 4:38 PM

It been too many years and Now I forgot how to write C code. This is what I have done so far - check to see if there are errors - I don't have compiler to run this code and I didn't print the values - so u have to do it urself. If this doesnot compile then - my bad - #include <stdio.h> #include<string.h> struct Person {   char name[15];   int weight;    }; int main() {  struct Person p[10];  int num, i, weight;  char name1[15];  printf("\n How many items do u need to enter(1-10) ");  scanf("%d",&num);  while(num>1 || num <10) {    printf("\n Re -enter number(1-10) ");    scanf("%n"+num);  }    for(i=0; i<num; i++) {    printf("\n Enter name ");     scanf("%s",name1);      p[i].name= name1;    printf("\n Enter weight ");    scanf("%d",&weight);      p[i].weight=weight;  }  return 0; }

serial · Feb 22, 2012 4:39 PM

 @ Serial  I truly thank you for helping me. It didn't work and I couldn't sort out what was wrong, but I appreciate your help. Thank you so much.

Udeshya · Feb 23, 2012 12:57 AM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all