Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id A33172E0031 for ; Tue, 20 May 2008 01:50:33 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 60485-02-8 for ; Tue, 20 May 2008 01:50:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from omr9.networksolutionsemail.com (omr9.networksolutionsemail.com [205.178.146.59]) by developer.postgresql.org (Postfix) with ESMTP id 660132E0097 for ; Tue, 20 May 2008 01:43:54 -0300 (ADT) Received: from mail.networksolutionsemail.com (ns-omr9.mgt.hosting.dc2.netsol.com [10.49.6.72]) by omr9.networksolutionsemail.com (8.13.6/8.13.6) with SMTP id m4K4hrGB030734 for ; Tue, 20 May 2008 00:43:53 -0400 Received: (qmail 30806 invoked by uid 78); 20 May 2008 04:43:53 -0000 Received: from unknown (HELO webmail35) (205.178.146.50) by ns-omr9.lb.hosting.dc2.netsol.com with SMTP; 20 May 2008 04:43:53 -0000 Received: from 24.175.78.74 (clarkhorse@clarktx.com [24.175.78.74]) by webmail35 (Netsol 11.2.30) with WEBMAIL id 23653; Tue, 20 May 2008 04:43:53 +0000 From: clarkhorse@clarktx.com To: "Jonah H. Harris" , clarkhorse@clarktx.com Cc: pgsql-interfaces@postgresql.org Importance: Normal Sensitivity: Normal Message-ID: X-Mailer: Network Solutions Webmail, Build 11.2.30 X-Originating-IP: [24.175.78.74] X-Forwarded-For: [(null)] Date: Tue, 20 May 2008 04:43:53 +0000 Subject: Re: Newbie problem with from database in C MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.599 tagged_above=0 required=5 tests=AWL=0.000, RCVD_NUMERIC_HELO=2.599 X-Spam-Level: ** X-Archive-Number: 200805/18 X-Sequence-Number: 6742 >> characters are fine so far. I have placed the code I am using below. >> Would appreciate it if someone could tell me what is wrong or provide me >> with a reference on how to do this properly. > >IIRC, you need to convert from network byte order: > >idno = ntohl(*((int32 *) PQgetvalue(result, row, 0))); > Thanks it led me in the right direction. I was getting confused with all of the pointers. I finally broke it down. int * idno; int idno2; idno = ((int32 *)PQgetvalue( result, row, 0)); idno2 = ntohl( * idno); So now that I look at this I don't understand why your statement didn't work. Okay redid it with idno2 = ntohl(*((int32 *) PQgetvalue(result, row, 0))); and it works. I was trying to put the int in a pointer for int. Thanks again, After googling this a number of different ways I found a number of people who never got a response. Most of their output was the same as mine before applying ntohl Output Translate to --------- ------------ 16777216 1 33554432 2 50331648 3 67108864 4 83886080 5 100663296 6 >-- >Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324 >EnterpriseDB Corporation | fax: 732.331.1301 >499 Thornall Street, 2nd Floor | jonah.harris@enterprisedb.com >Edison, NJ 08837 | http://www.enterprisedb.com/ > >-- >Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org) >To make changes to your subscription: >http://www.postgresql.org/mailpref/pgsql-interfaces >