🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2050

New2C: Problems understanding STRUCT Please HELP!!!!

#2050
From: Molle Anthony
Date: Sat, 17 Feb 1996 17:57
59 lines
1992 bytes
Hi, I've been working with C for about two weeks, and am having
problems with the whole "struct" concept.

My teacher has given me an assignment. I have to create a program that
will allow user's to add , delete, modify, and list items to a disk
file. 

I've decided to create a Video inventory list of sorts. I begin to
code and keep getting confused with what I can and cannot do with
struct.  Here is what I get

#include <stdio.h>

struct VideoFile
{    char name[25];
     char number[7];
     char qty[3];
};

main()
{    additem();      //teacher says to do this
     
  do   
     { printf("Enter another title?");
      
         /* checks to see if answer is 
                    yes or no or blablabla */
   
       additem();
      }  while (answer == 'Y');


additem()
{    
     inptr=fopen("a:\sample.txt","w+b");
     
     printf("Enter Video Title.");      /* I know that I should
     gets(Video.name);                       be calling the struct
     printf("Enter number.");               here somewhere, but
     gets(Video.number);                    where and how?   */
     printf("Enter Qty. ");
     gets(Video.qty);

     fclose(inptr);

     return;
}

My program is supposed to keep going from main to additem and back
until user says NO. Each time that I go tio additem, it opens, writes
to , and closes the SAMPLE file.   Teacher does not want any arrays to
be used.


THERE IT IS.  Can someone please help???!!!!!!!


     
     
Technical Details
Message-ID: <4g54v7$ap4@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: titan@atlas.odyssee.net (Molle Anthony)
Newsgroups: comp.lang.c.moderated
Subject: New2C: Problems understanding STRUCT Please HELP!!!!
Date: 17 Feb 1996 11:57:59 -0600
Organization: Odyssee Internet
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4g54v7$ap4@solutions.solon.com>
Reply-To: titan@atlas.odyssee.net
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: Forte Free Agent v0.55