1. Welcome to TRD Forums! A community for Toyota, Lexus, and Scion Enthusiasts. To enjoy all the benefits of the site, we invite you to signup.

Tech is there any good C programmers on here

Discussion in 'Off Topic' started by moonshadow, Jul 8, 2005.

  1. Offline

    moonshadow ||\\|||D)||\\||

    Message Count:
    1,274
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Jersey City, NJ
    is there any good C programmers on here

    i'm stuck on a little problem at work. i wrote a class to get me the machine ID for one of 700 database machines on our server farm and when it hits the instance of the class and calls the query it gives me a segmentation fault. i can post the code for the class if anyone can help :sad:
  2. Offline

    fishexpo101 Get Some

    Message Count:
    1,087
    Likes Received:
    3
    Trophy Points:
    488
    Location:
    Northern Virginia
    Sure, I'd post it up and see if anyone has an idea on it. Seg faults are pretty much a guarantee that some variable got memory mangled - can be hard to find, might not even have anything to do with the class that it stopped on. Did you run a debugger on it to determine where it stopped? Compiler used - MS Visual Studio, GCC, etc.?
  3. Offline

    moonshadow ||\\|||D)||\\||

    Message Count:
    1,274
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Jersey City, NJ
    yeah i narrowed it down. do you know much about the mysql c functions. lemme get the code.

    Code:
    int ServerID::queryid (MYSQL * mData)
    {
    #define __METHOD__ "queryid()"
    sprintf (id,"SHOW VARIABLES LIKE 'server_id'");
            if (mysql_real_query(mData, id, strlen(id)))
            {
                    printf ("Query failed: %s\n %s\n", id, mysql_error(mData));
            }
           // else
           // {
                    res = mysql_store_result(mData);
           // }
    return (0);
    #undef __METHOD__
    }
    
    from what i can narrow it down to its breaking at the mData which is a struct holding database information. i think its cuz i redeclare it as MYSQL * mData that it may be causing the problem cuz when i run it through a debugger it shows as being blank. I dont know though :superconf

    EDIT i use linux and i'm its g++
  4. Offline

    fishexpo101 Get Some

    Message Count:
    1,087
    Likes Received:
    3
    Trophy Points:
    488
    Location:
    Northern Virginia
    I haven't played with MySQL stuff - but it is all basically C/C++ stuff. The code snippet you posted here loks like it should not cause errors in some compilers - others will blow up as you have noticed. Linux doens't like null pointer assignments - Borland and Visual Studios will compile fine. Linux will tend to seg fault. Sorry - that wasn't very helpful. might want to try it at some of those guru sites and see what they say.

    Good Luck.
  5. Offline

    Roxtar New Member

    Message Count:
    47
    Likes Received:
    0
    Trophy Points:
    0
    i'm assuming you've tried various ways of de-referenceing your mData struct (*, &, etc)

    what are the different components of the struct that is being passed in? maybe in order to get this to work properly you need to reference the various parts of it (mData.int1 or mData->int1)

    (java/c++ programmer, not as much linux/c experience)
  6. Offline

    moonshadow ||\\|||D)||\\||

    Message Count:
    1,274
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Jersey City, NJ
    Roxtar: mData is a datahandle tahts not techincally a struct but has struct like properties. its one of the MySQL library functions. i'm still playing with it, if nothing the other guys should be back to work monday so i'll just ask one of them.

    fishexpo101: It doesnt if I run it independently. just the fact that it has to be called from an existing API is causing me headaches.
  7. Offline

    Barnacules 100101101011011

    Message Count:
    2,933
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Duvall, WA
    10 A$=w00t
    20 PRINT:A$
    30 GOTO 10

    Apple Basic Bizatch! :) hehehe.
  8. Offline

    Toxinate New Member

    Message Count:
    74
    Likes Received:
    0
    Trophy Points:
    0
    w00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00t
    w00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00t
    w00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00t
    w00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00t
    w00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00tw00t
    (ad infinitum)
  9. Offline

    Roxtar New Member

    Message Count:
    47
    Likes Received:
    0
    Trophy Points:
    0
    10 PRINT "w00t"
    20 GOTO 10

    qbasic and a more elegant solution bizatch!

    system.out.println("Hello World");
  10. Offline

    moonshadow ||\\|||D)||\\||

    Message Count:
    1,274
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Jersey City, NJ
    :rofl: gay both of you

Share This Page