Re: Newbie problem with from database in C

[email protected]
Newsgroups gmane.comp.db.postgresql.interfaces
Message-ID <W5766729606236531211258633@webmail35>

>> 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 | [email protected]
>Edison, NJ 08837 | http://www.enterprisedb.com/
>
>-- 
>Sent via pgsql-interfaces mailing list ([email protected])
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-interfaces
>



-- 
Sent via pgsql-interfaces mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.