From: | clarkhorse(at)clarktx(dot)com |
---|---|
To: | "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>, clarkhorse(at)clarktx(dot)com |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: Newbie problem with from database in C |
Date: | 2008-05-20 04:43:53 |
Message-ID: | W5766729606236531211258633@webmail35 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
>> 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(dot)harris(at)enterprisedb(dot)com
>Edison, NJ 08837 | http://www.enterprisedb.com/
>
>--
>Sent via pgsql-interfaces mailing list (pgsql-interfaces(at)postgresql(dot)org)
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-interfaces
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jonah H. Harris | 2008-05-20 13:36:03 | Re: Newbie problem with from database in C |
Previous Message | clarkhorse | 2008-05-19 06:47:57 | Re: Newbie problem with from database in C |