* Can't understand how to get needed pointer.
@ 2002-10-24 15:35 Ruslan U. Zakirov
2002-10-24 16:32 ` Tony Clarke
0 siblings, 1 reply; 2+ messages in thread
From: Ruslan U. Zakirov @ 2002-10-24 15:35 UTC (permalink / raw)
To: linux-c-programming
Hello.
I've wrote function that convert in_str from charset to UTF-8.
It uses libiconv.
int convert_str(char *in_str,const char *charset,char *out_str)
{
char *wrptr = (char *) out_str;
char inbuf[MAX_SIZE];
char *inptr = inbuf;
size_t insize = strlen(in_str)+1;
size_t avail = MAX_SIZE;
size_t nconv;
iconv_t cd;
sprintf (inbuf,"%s",in_str);
cd=iconv_open ("UTF-8",charset);
nconv = iconv (cd, &inptr, &insize, &wrptr, &avail);
iconv (cd, NULL, NULL, &wrptr, &avail);
iconv_close(cd);
return 0;
}
But I'v not understood how to get "const char* * inbuf" without
manipulations that I've done in code above. This code works fine, but
when I was compiling it gcc prints warning:
gd_ft_test.c: In function `convert_str':
gd_ft_test.c:83: warning: passing arg 2 of `iconv' from incompatible pointer type
I don't understand what I have to do with "char *in_str" to pass it to
iconv?
Here is declaration of function iconv:
size_t iconv (iconv_t cd,
const char* * inbuf, size_t * inbytesleft,
char* * outbuf, size_t * outbytesleft);
Thanks beforehead.
_________________________________________________________________________
Sorry for my English.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Can't understand how to get needed pointer.
2002-10-24 15:35 Can't understand how to get needed pointer Ruslan U. Zakirov
@ 2002-10-24 16:32 ` Tony Clarke
0 siblings, 0 replies; 2+ messages in thread
From: Tony Clarke @ 2002-10-24 16:32 UTC (permalink / raw)
To: Ruslan U. Zakirov; +Cc: linux-c-programming
Try changing the lines
char inbuf[MAX_SIZE];
char *inptr = inbuf;
to
const char inbuf[MAX_SIZE];
const char * inptr = inbuf;
The warning should go away then, i think...
Tony
>Hello.
>I've wrote function that convert in_str from charset to UTF-8.
>It uses libiconv.
>int convert_str(char *in_str,const char *charset,char *out_str)
>{
> char *wrptr = (char *) out_str;
> char inbuf[MAX_SIZE];
> char *inptr = inbuf;
> size_t insize = strlen(in_str)+1;
> size_t avail = MAX_SIZE;
> size_t nconv;
>
> iconv_t cd;
> sprintf (inbuf,"%s",in_str);
> cd=iconv_open ("UTF-8",charset);
> nconv = iconv (cd, &inptr, &insize, &wrptr, &avail);
> iconv (cd, NULL, NULL, &wrptr, &avail);
> iconv_close(cd);
> return 0;
>}
>But I'v not understood how to get "const char* * inbuf" without
>manipulations that I've done in code above. This code works fine, but
>when I was compiling it gcc prints warning:
> gd_ft_test.c: In function `convert_str':
> gd_ft_test.c:83: warning: passing arg 2 of `iconv' from incompatible pointer type
>I don't understand what I have to do with "char *in_str" to pass it to
>iconv?
>Here is declaration of function iconv:
>size_t iconv (iconv_t cd,
> const char* * inbuf, size_t * inbytesleft,
> char* * outbuf, size_t * outbytesleft);
>
>Thanks beforehead.
>_________________________________________________________________________
>Sorry for my English.
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-24 16:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-24 15:35 Can't understand how to get needed pointer Ruslan U. Zakirov
2002-10-24 16:32 ` Tony Clarke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.