Thread: array equal to another array

  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,708
    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 <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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 09: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,708
    Is 'record' an array?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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, 01: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