forcing signed into unsigned

This is a discussion on forcing signed into unsigned within the C++ Programming forums, part of the General Programming Boards category; Why isn't this working...? Yes, I am trying to force signed into unsigned. By dereferencing the LHS I hope to ...

  1. #1
    Registered User Dave++'s Avatar
    Join Date
    Jun 2007
    Location
    Where the Buffalo Roam
    Posts
    40

    Lightbulb forcing signed into unsigned

    Why isn't this working...?

    Yes, I am trying to force signed into unsigned.
    By dereferencing the LHS I hope to accomplish the conversion.
    It's the segmentation fault that concerns me.
    I'm curious to know what bounds of programming I've exceeded?
    Thanks in advance...Dave++

    Code:
    unsigned long* scalerData[COUNTERS];
    long Data;
    ...
    call function(){
     for(int i=0; i<COUNTERS; i++){
        this->Read32Counter(i, &Data);  // Read32Counter(int, long*)
        *this->scalerData[i] = Data;       // *this->... causes segmentation fault                           
        // this->scalerData[i] = &Data;   // error: pointers of non-equal type

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    It might be better to declare scalarData like this:
    Code:
    unsigned long scalerData[COUNTERS];
    And then you can do:
    Code:
        scalerData[i] = Data;

  3. #3
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    905
    Apparently, you don't have access to *scalarData[...]

    Do those pointers lead to locally-allocated memory?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,243
    Quote Originally Posted by Dave++ View Post
    Code:
    *this->scalerData[i] = Data;       // *this->... causes segmentation fault
    This line seems odd. Are you sure you need that star? Without seeing details of the types involved, there's no way to tell. Do you get any warnings anywhere?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 08-11-2008, 11:02 PM
  2. Heap corruption using zlib inflate
    By The Wazaa in forum C++ Programming
    Replies: 0
    Last Post: 03-29-2007, 12:43 PM
  3. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  4. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM

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