converting struct to tables in turbo c++

This is a discussion on converting struct to tables in turbo c++ within the C++ Programming forums, part of the General Programming Boards category; hello, I want to know how to convert struct to tables in turbo c++ . that means when the user ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    converting struct to tables in turbo c++

    hello,

    I want to know how to convert struct to tables in turbo c++ . that means when the user enter the informations it will be saved in tables ( matrice ) and not structure.

    Exemple:

    This was the declaration part of the structure in my project.

    Code:
    typedef struct
    {
    char nom[50];
    char nomau[50];
    char maison[100];
    char pages[20];
    char type[20];
    char code[20];
    
    }Annu;
    Annu tab[50];
    After the user enter the informations it will be copied in the strcture:

    Code:
    if(m==1) strcpy(tab[j].nom,c1);
    if(m==2) strcpy(tab[j].nomau,c1);
    if(m==3) strcpy(tab[j].maison,c1);
    if(m==4) strcpy(tab[j].pages,c1);
    if(m==5) strcpy(tab[j].type,c1);
    if(m==6) strcpy(tab[j].code,c1);
    However i want the informations to be copied into a table ( matrice).

    Let me know with examples if you don't mind.

    Thanks in advance.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I don't quite understand your question, what do you want your matrix to look like?

    And by the way:
    Code:
    if(m==1) strcpy(tab[j].nom,c1);
    if(m==2) strcpy(tab[j].nomau,c1);
    if(m==3) strcpy(tab[j].maison,c1);
    if(m==4) strcpy(tab[j].pages,c1);
    if(m==5) strcpy(tab[j].type,c1);
    if(m==6) strcpy(tab[j].code,c1);
    This code is perfect for using switch()/case.
    --
    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.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,609
    Why use Turbo C++? Are you allowed / can you use other compilers?
    If so, then I strongly suggest you upgrade.
    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.

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    2
    matsp, in my project I'm not allowed to use structures, ONLY tables ( matrix ) that is why i must convert it to tables.

    Elysia, graphic mode in Turbo c++ is the subject of all my project so i can't upgrade to a newer compiler.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,728
    What do you mean by a table or a matrix? As in a table/matrix class that is given to you?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-20-2009, 11:37 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  4. Bi-Directional Linked Lists
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 12-11-2003, 09:24 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21