Connecting Tech Pros Worldwide Forums | Help | Site Map

char syntax question

Frits JK
Guest
 
Posts: n/a
#1: Jul 22 '05
Please help.



I have to make a little change to a DLL , original there was a static char
szIPAddr, and I want to make it variable. Unfortunately I am not good enough
with C++ syntax







original syntax was :

//-----------------------------------------------------------------



extern "C" int PASCAL EXPORT ReadMidi( void )



{



static char szIPAddr[32] = { "10.0.0.4" } ;

static struct sockaddr_in sa ;

sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;







Desired syntax

//------------------------------------------------------------------



extern "C" int PASCAL EXPORT ReadMidi( char szIPAddr )



{



static struct sockaddr_in sa ;

sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;







this gives error :

: error C2664: 'inet_addr' : cannot convert parameter 1 from 'char' to
'const char *'

Conversion from integral type to pointer type requires reinterpret_cast,
C-style cast or function-style cast







Regards,

Frits Janse Kok



Thomas Matthews
Guest
 
Posts: n/a
#2: Jul 22 '05

re: char syntax question


Frits JK wrote:[color=blue]
> Please help.
>
> I have to make a little change to a DLL , original there was a static char
> szIPAddr, and I want to make it variable. Unfortunately I am not good enough
> with C++ syntax
>
> original syntax was :
>
> //-----------------------------------------------------------------
> extern "C" int PASCAL EXPORT ReadMidi( void )
> {
> static char szIPAddr[32] = { "10.0.0.4" } ;[/color]
Note that the above variable is an array of characters,
not just a single one.

[color=blue]
> static struct sockaddr_in sa ;
> sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;
>
> Desired syntax
>
> //------------------------------------------------------------------
> extern "C" int PASCAL EXPORT ReadMidi( char szIPAddr )[/color]
This should be:
extern "C" int PASCAL EXPORT ReadMidi(char * szIPAddr)
Note the location of '*'.

[color=blue]
> {
> static struct sockaddr_in sa ;
> sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;
>
> Regards,
>
> Frits Janse Kok
>
>[/color]


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Frits JK
Guest
 
Posts: n/a
#3: Jul 22 '05

re: char syntax question


That works !!
Thank you very much for the quick reaction.

Frits Janse Kok


"Thomas Matthews" <Thomas_MatthewsSpitsOnSpamBots@sbcglobal.net> schreef in
bericht news:IQCCc.3697$mn7.3256@newssvr32.news.prodigy.co m...[color=blue]
> Frits JK wrote:[color=green]
> > Please help.
> >
> > I have to make a little change to a DLL , original there was a static[/color][/color]
char[color=blue][color=green]
> > szIPAddr, and I want to make it variable. Unfortunately I am not good[/color][/color]
enough[color=blue][color=green]
> > with C++ syntax
> >
> > original syntax was :
> >
> > //-----------------------------------------------------------------
> > extern "C" int PASCAL EXPORT ReadMidi( void )
> > {
> > static char szIPAddr[32] = { "10.0.0.4" } ;[/color]
> Note that the above variable is an array of characters,
> not just a single one.
>
>[color=green]
> > static struct sockaddr_in sa ;
> > sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;
> >
> > Desired syntax
> >
> > //------------------------------------------------------------------
> > extern "C" int PASCAL EXPORT ReadMidi( char szIPAddr )[/color]
> This should be:
> extern "C" int PASCAL EXPORT ReadMidi(char * szIPAddr)
> Note the location of '*'.
>
>[color=green]
> > {
> > static struct sockaddr_in sa ;
> > sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;
> >
> > Regards,
> >
> > Frits Janse Kok
> >
> >[/color]
>
>
> --
> Thomas Matthews
>
> C++ newsgroup welcome message:
> http://www.slack.net/~shiva/welcome.txt
> C++ Faq: http://www.parashift.com/c++-faq-lite
> C Faq: http://www.eskimo.com/~scs/c-faq/top.html
> alt.comp.lang.learn.c-c++ faq:
> http://www.raos.demon.uk/acllc-c++/faq.html
> Other sites:
> http://www.josuttis.com -- C++ STL Library book
>[/color]


Victor Bazarov
Guest
 
Posts: n/a
#4: Jul 22 '05

re: char syntax question


Frits JK wrote:[color=blue]
> Please help.
>
>
>
> I have to make a little change to a DLL , original there was a static char
> szIPAddr, and I want to make it variable. Unfortunately I am not good enough
> with C++ syntax[/color]

If you're not "good enough" (and this 'char' business is really very
basic stuff), you should not attempt changing a DLL... Just a thought.
[color=blue]
>
>
>
>
>
>
>
> original syntax was :
>
> //-----------------------------------------------------------------
>
>
>
> extern "C" int PASCAL EXPORT ReadMidi( void )
>
>
>
> {
>
>
>
> static char szIPAddr[32] = { "10.0.0.4" } ;
>
> static struct sockaddr_in sa ;
>
> sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;
>
>
>
>
>
>
>
> Desired syntax
>
> //------------------------------------------------------------------
>
>
>
> extern "C" int PASCAL EXPORT ReadMidi( char szIPAddr )[/color]

Make it

extern "C" int PASCAL EXPORT ReadMidi( char const * szIPAddr )
[color=blue]
>
>
>
> {
>
>
>
> static struct sockaddr_in sa ;
>
> sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;[/color]
Closed Thread


Similar C / C++ bytes