C++ Image Upload Problem

Started by
12 comments, last by neob 17 years, 2 months ago
Quote:Original post by neob
do you know a better "bitmap upload to program" source code?

Well, DevIL (Developer's Image Library) will load MANY types of images. It's also well tested. And portable. And highly recommended by me. [wink]

Google can help you find it. Its site has tutorials for you. Lots of other places have examples.

Not that this one won't be functional or anything, and it's a good exercise for you. Add the library and switch to std::strings, and I think you'll be well on your way.

-jouley
Advertisement
Quote:Original post by neob
Quote:
When you use single quotes around something, it means it's a character. "MB" is two characters ;).


I think I miss understood you, but do you mean that I can only use 'M' and it cannot be 'MB' - that makes no sense to me.


When you use single quotes like this: 'M' it means it's a character. You're trying to do a string comparison, so you need double quotes "MB" because MB is two characters and therefore no longer a single character.

Does this make sense?
To quote the C++ Standard, section 2.13.2, paragraph 1
A  character  literal  is  one  or  more characters enclosed in singlequotes, as in 'x', optionally preceded by the letter L, as in L'x'.  Acharacter  literal that does not begin with L is an ordinary characterliteral, also referred to as a narrow-character literal.  An  ordinarycharacter  literal  that  contains a single c-char has type char, withvalue equal to the numerical value of the encoding of  the  c-char  inthe  execution character set.  An ordinary character literal that con-tains more than one c-char is a multicharacter literal.  A  multichar-acter literal has type int and implementation-defined value.

Your 'MB' is a multicharacter literal.

To make it is hell. To fail is divine.

Thank you all.

This topic is closed to new replies.

Advertisement