Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 558181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:06:17+00:00 2026-05-13T12:06:17+00:00

I found that handy opencv library and tried to program a simple imagemodifier with

  • 0

I found that handy opencv library and tried to program a simple imagemodifier with it using C. When I started to compile my code I got some errors, that are a bit confusing as they doesn’t seem to make sense. This is my first time when programming with netbeans and first time I’m trying to make something else than those basic calculator etc. programs. Below is the code and the errors the compiler gives:

int iscolor = -1; /* Used to load the image as it is*/
IplImage* image = 0;

/* Load Image */
image = cvLoadImage(const char* 'test.jpg', iscolor); /* line 34 */

/*Modify image*/
...

/* Save Image */
int cvSaveImage(const char* 'modified.jpg', const CvArr* image); /* line 43 */

/*End*/

Compiler errors

main.c: In function ‘main’:

main.c:34: error: expected expression
before ‘const’

main.c:34:37: warning: character
constant too long for its type

main.c:34: error: too few arguments to
function ‘cvLoadImage’

main.c:43:33: warning: character
constant too long for its type

main.c:43: error: expected ‘;’, ‘,’ or
‘)’ before ‘\x2e6a7067’

These errors confuses me a bit, because

  1. referring to opencv c reference cvLoadImage takes just two arguments.

  2. how come character constant is too long?

  3. expected expression before ‘const’? hummm… I don’t get this at all

  4. expected ‘;’, ‘,’ or ‘)’ before ‘\x2e6a7067’… well I don’t get this either

    So can somebody tell me what I’m doing wrong? Any help would be nice 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:06:17+00:00Added an answer on May 13, 2026 at 12:06 pm

    In C, single quotes are used to denote single (literal) character constants, and the resulting type of such constants is int. So, 'a' is OK, 'a1' is not, because that’s two characters. C defines some escape sequences, for example '\n', which is treated as one character signifying a newline, or '\xff', which is the character with hexadecimal value 0xff. Since 'test.jpg' contains more than one character, the compiler is telling you that your literal character constant is too long. You want a string, which needs double quotes.

    You need to put parentheses around a cast: (const char *)x is okay, const char * x is not (well it is okay if you are declaring x as a const char *). I think you added that cast because the compiler was warning you about “converting int to pointer without a cast”. In general, unless you really know what you’re doing, casting to silence the compiler is a very bad idea.

    Based upon the above, Line 34 should be:

    image = cvLoadImage("test.jpg", iscolor);
    

    If you really want to cast "test.jpg" as const char *, do:

    image = cvLoadImage((const char *)"test.jpg", iscolor);
    

    Also, now you know how to fix this line:

    int cvSaveImage(const char* 'modified.jpg', const CvArr* image);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst refactoring some legacy C++ code I found that I could potentially remove some
We’ve found that the unit tests we’ve written for our C#/C++ code have really
I've found that on some occasions I can edit the source while debugging. Are
I have found that my HTML is, to be honest, very clunky. Small, simple
I've been parsing through some log files and I've found that some of the
I'm using a RichTextBox in WinForms 3.5 and I found that when I programmatically
I found this handy piece of code to determine if my app is in
I have found that there is generally a singe type or namespace that takes
I've installed Ubuntu Server (8.04) into Parallels and found that the system time/clock ran
After trying to setup my site for Google Webmaster Tools I found that my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.