Jump to content

Special letters in c

I started programming in c programming language and I have a problem with special letter such as č ć ž š  or  đ(letters used in Croatian, Serbian and Bosnian), I need this letter for my new program but I don't now which library should I use to add them, so can someone help please by providing a link or straight up saying how to do it, I am working in visual express 2012.

Link to comment
Share on other sites

Link to post
Share on other sites

You cannot use them for naming your variables. You can perfectly use them inside strings.

Use charmap (Win+R, charmap, Enter).

Write in C.

Link to comment
Share on other sites

Link to post
Share on other sites

Windows uses UTF-16, your code obviously does not.

Write in C.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Dat Guy said:

Windows uses UTF-16, your code obviously does not.

sorry for asking but can you explain that.....I am new to programming

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, ficoblooder said:

sorry for asking but can you explain that.....I am new to programming

UTF-16 is a character encoding. This is just what defines a ID to all the different charecters there are in the alphabet. Since UTF-16 does not include č ć ž š it cannot display them because it doesn't know what they are.

Wikipedia

Please mention or quote me if you want a response. :) 

¯\_(ツ)_/¯

¯\_(ツ)_/¯

¯\_(ツ)_/¯

¯\_(ツ)_/¯

¯\_(ツ)_/¯

¯\_(ツ)_/¯

Link to comment
Share on other sites

Link to post
Share on other sites

You should try this:

Quote
include <stdio.h>
#include <locale.h>
 
int main(void)
{
    setlocale(LC_CTYPE,"");
    printf("âÄÂéOUÜö\n");
 
    return 0;
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

As others have said, it's a character encoding thing. It's not an out of the box thing with C, and you have to be mindful about it and learn how to deal with encodings. This is just how it is really, C is quite a low level programming language in today's standards, a lot of things are done manually.

 

Read about encodings, starting with ASCII, and understand how they're represented. You'll have a better idea of what's going on and why you get question marks. That string of characters contains UTF characters, but in C it's still represented as a bunch of bytes that the terminal cannot understand because it's not set to do that. That is what setlocale does.

Link to comment
Share on other sites

Link to post
Share on other sites

Code is written in English, well its version of English anyways. No none English symbols and characters, sorry. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×