Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > char syntax question

Reply
Thread Tools

char syntax question

 
 
Frits JK
Guest
Posts: n/a
 
      06-24-2004
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


 
Reply With Quote
 
 
 
 
Thomas Matthews
Guest
Posts: n/a
 
      06-24-2004
Frits JK wrote:
> 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" } ;

Note that the above variable is an array of characters,
not just a single one.


> 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 )

This should be:
extern "C" int PASCAL EXPORT ReadMidi(char * szIPAddr)
Note the location of '*'.


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



--
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

 
Reply With Quote
 
 
 
 
Frits JK
Guest
Posts: n/a
 
      06-24-2004
That works !!
Thank you very much for the quick reaction.

Frits Janse Kok


"Thomas Matthews" <(E-Mail Removed)> schreef in
bericht news:IQCCc.3697$(E-Mail Removed) m...
> Frits JK wrote:
> > 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" } ;

> Note that the above variable is an array of characters,
> not just a single one.
>
>
> > 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 )

> This should be:
> extern "C" int PASCAL EXPORT ReadMidi(char * szIPAddr)
> Note the location of '*'.
>
>
> > {
> > static struct sockaddr_in sa ;
> > sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;
> >
> > Regards,
> >
> > Frits Janse Kok
> >
> >

>
>
> --
> 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
>



 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      06-24-2004
Frits JK wrote:
> 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


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.

>
>
>
>
>
>
>
> 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 )


Make it

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

>
>
>
> {
>
>
>
> static struct sockaddr_in sa ;
>
> sa.sin_addr.S_un.S_addr = inet_addr (szIPAddr) ;

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
char *fred; char * fred; char *fred; any difference? Ben Pfaff C Programming 5 01-17-2004 07:37 PM
The difference between char a[6] and char *p=new char[6] ? wwj C Programming 24 11-07-2003 05:27 PM
the difference between char a[6] and char *p=new char[6] . wwj C++ 7 11-05-2003 12:59 AM



Advertisments