array equal to another array

This is a discussion on array equal to another array within the C++ Programming forums, part of the General Programming Boards category; Code: do { cout << "\nStudent ID found"; cout << "\nNow deleting student profile"; record.Fname[x] = record.Fname[x][x]; record.Lname[x] = record.Lname[x+1]; ...

  1. #1
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294

    array equal to another array

    Code:
    do {
    				cout << "\nStudent ID found";
    				cout << "\nNow deleting student profile";
    			
    				record.Fname[x] = record.Fname[x][x];
    				record.Lname[x] = record.Lname[x+1];
    				record.Cname[x] = record.Cname[x+1];
    				record.Sid[x] = record.Sid[x+1];
    				record.Cid[x] = record.Cid[x+1];
    				record.Smark[x] = record.Smark[x+1];
    				x++;
    			}while (x!=record.key);
    i want to assign the next value of the same array to the present value , but for some reason it gives me error... suggestions?
    Games Reviews Previews Desktop Themes Downloads Paintball Forums Shareware Freeware and much more

    The best in Technology and Gaming News

    www.back2games.com

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    That's not a lot of code to go off of, but the obvious problem occurs on this line:
    Code:
    record.Fname[x] = record.Fname[x][x];
    Also, if any of those are pointers (esp. char*), then presumably you want to do a deep copy (copy the contents of the pointer, not the pointer itself). Otherwise, you'd have to do a good bit of extra work to make sure there are non memory errors.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,648
    Couple problems.

    To index an array of structures is the same for any other data type.

    structure[index]

    To access the data in the structure at that index would then be:

    structure[index].member

    Next problem:

    >> record.Fname[x] = record.Fname[x][x];

    Typo?

    Finally, if Lname, for instance, is a character array, you need to use something like strcpy(), since char * = char * is not what you want - right?
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  4. #4
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294
    ya it was typo
    it is : record.Fname[x] = record.Fname[x+1];

    thxs it works
    Last edited by dayknight; 11-28-2003 at 08:45 AM.
    Games Reviews Previews Desktop Themes Downloads Paintball Forums Shareware Freeware and much more

    The best in Technology and Gaming News

    www.back2games.com

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,648
    Is 'record' an array?
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  6. #6
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294
    it works
    Games Reviews Previews Desktop Themes Downloads Paintball Forums Shareware Freeware and much more

    The best in Technology and Gaming News

    www.back2games.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 11-25-2008, 12:50 AM
  2. Creating a menu that reads input via an array?
    By Nalif in forum C Programming
    Replies: 6
    Last Post: 09-29-2006, 09:21 PM
  3. 1-D array
    By jack999 in forum C++ Programming
    Replies: 24
    Last Post: 05-12-2006, 07:01 PM
  4. 2d array question
    By gmanUK in forum C Programming
    Replies: 2
    Last Post: 04-21-2006, 12:20 PM
  5. Trouble making an Array equal a Function
    By Ozor in forum C++ Programming
    Replies: 16
    Last Post: 07-11-2003, 10:33 AM

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