Thread: Setting a user's input as the structure name

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    3

    Setting a user's input as the structure name

    Hi there, i am looking for some help in structures.

    I am not sure if i am going about this the right way but i am looking to use structures to store multipul details of one panel.

    How does the basic struct work?

    for instance, if the structure is:
    Code:
    struct panel
     {
       char name[25];
       int age;
       float cost;
     };
    how do i add an additional panel and then how do i recall specific infomation about this panel?

    i am worried about having to have:

    Code:
    struct panel1
     {
       char name[25];
       int age;
       float cost;
     };
    
    struct panel2
     {
       char name[25];
       int age;
       float cost;
     };
    etc...

    and only being able to have a finite number of panels.

    I am I am missing something basic here, but could someone explain for me?

    also i intend to store the info in a data file so when the user re-opens the program, (s)he is able to say load panel, and the program lists the previously saved panels, allowing the specific panel's details to be loaded for editing.

    Any help would be awesome

    Ste

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    structs are blueprints; you must create them first. Thus, you can create an almost infinite amount of structs from the blueprint. You don't need several structs with the same data.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    To me, it sounds like you actually want to store the users input as a filename, and restore it based on what name the user gives.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    45
    Code:
    struct panel
     {
       char name[25];
       int age;
       float cost;
     };
    
    panel many_panels[10000];

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with a lab
    By michael- in forum C Programming
    Replies: 18
    Last Post: 12-06-2005, 11:28 PM
  2. Reading a string from an input file into a structure
    By Maxwell25 in forum C++ Programming
    Replies: 15
    Last Post: 05-01-2003, 10:30 AM
  3. cin.getline question (user's input too long)
    By JerryL_MB in forum C++ Programming
    Replies: 1
    Last Post: 12-09-2002, 12:17 PM
  4. limiting length of users input
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-20-2001, 09:55 AM