Thread: converting struct to tables in turbo c++

  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をこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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
    28,413
    What do you mean by a table or a matrix? As in a table/matrix class that is given to you?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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-21-2009, 12:37 AM
  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, 10:24 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM