0

i'm trying to design a c program that will help newcomers to the Internet understand certain abbreviations.I have 8 abbreviations such as AFAIK - as far as i know etc. I am storing the abbreviations in one array [][8],and the descriptions in another[][8] and initialising them. BUT, I don't know how to link the two arrays together. I think I have to copy one string to another, but not sure what the loop is. I haven't been taught pointers yet, but i know I need to use strcpy. Can someone please help?

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Infarction
0

Here is a small example on how to do it, you can easily mould it to your needs:

#include <iostream>
#include <cstring>

int main()
{
    char* digit[] = { "1", "2", "3", "4" } ;
    char* number[] = { "one", "two", "three", "four" } ;

    for( int i = 0; i < 4; ++i )
    {
        std::cout << digit[i] << " is equivalent to " << number[i] << std::endl ;
    }
    return 0 ;
}
0

The most basic way to keep them together is to do as ~s.o.s~ did by having them ordered the same, so that a given index into one array will correspond to the same index into the other array. If you're just starting in C, this is probably the best way to go for now...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.