From: clarkhorse@clarktx.com
To: Jonah H. Harris <jonah.harris@gmail.com>
To: clarkhorse@clarktx.com
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Newbie problem with from database in C
Date: Tue, 20 May 2008 04:43:53 +0000
Message-ID: <W5766729606236531211258633@webmail35> (raw)
>> 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
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: clarkhorse@clarktx.com, jonah.harris@gmail.com
Subject: Re: Newbie problem with from database in C
In-Reply-To: <W5766729606236531211258633@webmail35>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox