Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![kencook](https://uploads.teamtreehouse.com/production/profile-photos/1701002/micro_ewgnew.jpg)
kencook
4,375 PointsDifferences between char & int?
Are there any more distinguishable differences between int and char in C?
It sounds like int can hold a whole number, and char can hold a number or a letter. Are there any other differences between the two? When would use use char over int, or int over char?
1 Answer
![Jayden Spring](https://uploads.teamtreehouse.com/production/profile-photos/826502/micro_577288_10151893590733694_2080171088_n.jpg)
Jayden Spring
8,625 PointsBig difference - char is really the most basic type accessible to a programmer. I would suggest having a read of The C Programming Language from Kernighan & Ritchie to understand in detail.
Petar Brkovic said that never to use char for a number - which is correct to an extent. A char is an integer, just one which you will never see as that integer is machine code (ie 0's or 1's). Char's are individual characters, for example you can store a line of text in an array of type char with an allocated size that matches the size of your string. Or if you wanted to change the 4th letter of a word from upper to lower you could turn the Unicode String into a w_char or char and then access the letter at position [3] in an array and transform it. Have a look at this page here for more on Chars
Petar Brkovic
8,651 PointsPetar Brkovic
8,651 PointsChar is short for character, and should be used for strings. Int is used for whole numbers.
Never use char for number.
I'm not sure that this logic of mine is 100% true, so please if someone knows better, correct me.