non ascii chracter problem

B

Burak

i'll try to explain my problem shortly...

char wrt[50];
char word[50];

strcpy(wrt,"şç");
printf("%s\n",wrt);
//i get ■ as output

gets(word); //i will write şç
printf("%s \n",word);
//output of this is correct,şç

How can i solve this?
Any suggestions?
 
C

CBFalconer

Burak said:
i'll try to explain my problem shortly...

char wrt[50];
char word[50];

strcpy(wrt,"şç");
printf("%s\n",wrt);
//i get ■ as output

gets(word); //i will write şç
printf("%s \n",word);
//output of this is correct,şç

How can i solve this?
Any suggestions?

Never, ever, under any circumstances, use gets(). You can get a
replacement (with equal convenience that can be used safely) in
ggets(). You will find it at:

<http://cbfalconer.home.att.net/download/>
 
R

Richard

CBFalconer said:
Burak said:
i'll try to explain my problem shortly...

char wrt[50];
char word[50];

strcpy(wrt,"şç");
printf("%s\n",wrt);
//i get ■ as output

gets(word); //i will write şç
printf("%s \n",word);
//output of this is correct,şç

How can i solve this?
Any suggestions?

Never, ever, under any circumstances, use gets(). You can get a
replacement (with equal convenience that can be used safely) in
ggets(). You will find it at:

<http://cbfalconer.home.att.net/download/>

gets can be and is used perfectly safely in many controlled
situations. Advisable to use it? Probably not. ggets has its own issues
IMO.
 
K

Keith Willis

gets can be and is used perfectly safely in many controlled
situations. Advisable to use it? Probably not. ggets has its own issues
IMO.

I'm puzzled.
1. How could gets be used "perfectly safely"?
2. What on earth is wrong with fgets()? [f]ggets makes me free memory
that it allocated, whereas with fgets, I can sort out my own
allocation as and when (and however) I want to.
 
R

Richard

Keith Willis said:
I'm puzzled.
1. How could gets be used "perfectly safely"?

if you know the problems with it in a badly controlled environment then
it doesn't take a leap of faith to figure out how it can be used safely
- when you totally control the input stream e.g another process.
2. What on earth is wrong with fgets()? [f]ggets makes me free memory
that it allocated, whereas with fgets, I can sort out my own
allocation as and when (and however) I want to.

Nothing is wrong with fgets. Did anyone say there is?
 
B

Ben Bacarisse

Burak said:
i'll try to explain my problem shortly...

char wrt[50];
char word[50];

strcpy(wrt,"şç");
printf("%s\n",wrt);
//i get ■ as output

gets(word); //i will write şç
printf("%s \n",word);
//output of this is correct,şç

How can i solve this?

These things are very hard to debug over Usenet. I can not be sure of
what you have in your C file or in your output since simply copying
into a message can change the character encoding.
Any suggestions?

Best guess: the program you use to type in your C code uses a
different character encoding from the terminal/console you run it on.
To get a better-informed guess, ask in a group that knows about your
development environment.
 
C

CBFalconer

Keith said:
Richard said:
gets can be and is used perfectly safely in many controlled
situations. Advisable to use it? Probably not. ggets has its own
issues IMO.

I'm puzzled.
1. How could gets be used "perfectly safely"?
2. What on earth is wrong with fgets()? [f]ggets makes me free
memory that it allocated, whereas with fgets, I can sort out
my own allocation as and when (and however) I want to.

I did NOT say gets can be used safely. I recommended ggets. Note
the extra g. There is nothing wrong with fgets if you can put up
with its nuisances, such as not knowing whether the line is
complete without checking for a terminal '\n'. In many cases the
first thing you are going to do with an incoming line is allocate
memory to hold it, and tuck it away. No need with ggets.

A routine is only useful if it fits your practice. The ggets
package includes usage examples.

Incidentally, "Richard <[email protected]>" is plonked here, because
his recommendations are generally idiotic. This includes his
quoted advice above.
 
R

Richard Bos

gets can be and is used perfectly safely in many controlled situations.

Not legally in states where bondage gear falls under the local obscenity
laws.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top