🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.oracle.misc
Article #80

Pro*C: copying VARCHAR into char*

#80
From: Serge LUCAS
Date: Mon, 22 Feb 1999 00:00
36 lines
1527 bytes
I have declared in SQL-Pro*C a VARCHAR variable:
	VARCHAR SRC[30];
developped by the precompiler as:
	struct {unsigned short int len;unsigned char* arr;} SRC;

and want to copy it in a char*:
	strncpy(dest,SRC.arr,SRC.len);

Strncpy copies 'len' characters of SRC in dest, but does not copy a '\0'
at the end.
So I must add :
	dest[SRC.len]='\0';

but Is there a better way to do it, in one line for exemple:
	recopy(dest, SRC) ???

If I try to define :
	struct OracleVARCHARtype {unsigned short int len;unsigned char* arr;};
and:
	void recopy(char* dest, OracleVARCHARtype src)
	{
	 strncpy(dest, src.arr,src.len);
	 dest[src.len]='\0';
	}

I have many syntax errors of the C++ compiler.
(parameter not defined const, unsigned char* instead of char*, etc...)

Does somebody has a solution ?
-- 
Serge LUCAS
STERIA ATM/Eurocontrol
BS-012
Tel 01 69 88 74 15
Fax 01 69 88 73 33
Mel lua@eurocontrol.fr
Technical Details
Message-ID: <36D122F1.E575375C@eurocontrol.fr>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f99a8,e806d04e31c4710b,start
X-Google-Attributes: gidf99a8,public
X-Google-Thread: fdcad,e806d04e31c4710b,start
X-Google-Attributes: gidfdcad,public
From: Serge LUCAS <Serge.Lucas@eurocontrol.fr>
Subject: Pro*C: copying VARCHAR into char*
Date: 1999/02/22
Message-ID: <36D122F1.E575375C@eurocontrol.fr>
X-Deja-AN: 447001379
Content-Transfer-Encoding: 7bit
Organization: EUROCONTROL Experimental Centre
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: comp.databases.oracle.misc,fr.comp.lang.c++