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 743833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:54:32+00:00 2026-05-14T08:54:32+00:00

I don’t know the cause of these errors I am receiving from Visual Studio

  • 0

I don’t know the cause of these errors I am receiving from Visual Studio 2010.

This is the code from my program from line 343 to line 408:

int create_den_from_img(char *img_file_name_part, int xlen, int ylen, int zlen )
{
  IplImage* imgs = 0;
  char str[80];
  unsigned char *data,*imgdata;

  /* allocating memory */
  data = (unsigned char *) malloc(xlen * ylen * zlen * sizeof(unsigned char) );
  if(data==NULL)
  {
    printf("error in allocating memory \n");
    exit(1);
  }

  /* Getting the filename & iterating through tiff images */

    for(int k = 0; k < zlen; k++)
    {   
        int count=2;
        int tmp=k+1;
        while(tmp/10)
        {
            count=count-1;
            tmp=tmp/10;
        }

        switch(count)
        {
            case 2:sprintf(str,"%s00%d.tif",img_file_name_part,k+1);
                    break;
            case 1:sprintf(str,"%s0%d.tif",img_file_name_part,k+1);
                    break;  
            default:sprintf(str,"%s%d.tif",img_file_name_part,k+1);
                    break;
        }
        printf("%s\n",str);

        /* Loading Image using OpenCV */
        imgs=cvLoadImage(str,-1);
        if(imgs==NULL)
        {
            printf("error in opening image \n");
            exit(1);
        }
        imgdata=(uchar *)imgs->imageData;

        for(int j =0; j < ylen; j++)
        {
            for(int i =0; i < xlen; i++)
            {
                data[ k*xlen*ylen + j*xlen + i ] = imgdata[ j*xlen+i ];
            }
        }

        cvReleaseImage(&imgs );
    }

    /* populating `data` variable is done. So, calling `write_den` */
    if(write_den("test.den",data,xlen,ylen,zlen)==0)
    {
        printf("Error in creating den file\n");
        exit(1);
    }
    printf("Den file created\n");

}

These are the list of errors:

Error   3   error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   358 1   MTP_TEST
Error   4   error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   358 1   MTP_TEST
Error   5   error C2143: syntax error : missing ')' before 'type'   c:\examples\denfile.c   358 1   MTP_TEST
Error   6   error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   358 1   MTP_TEST
Error   7   error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   358 1   MTP_TEST
Error   9   error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   358 1   MTP_TEST
Error   10  error C2059: syntax error : ')' c:\examples\denfile.c   358 1   MTP_TEST
Error   11  error C2143: syntax error : missing ';' before '{'  c:\examples\denfile.c   359 1   MTP_TEST
Error   12  error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   361 1   MTP_TEST
Error   13  error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   370 1   MTP_TEST
Error   14  error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   372 1   MTP_TEST
Error   15  error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   374 1   MTP_TEST
Error   16  error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   388 1   MTP_TEST
Error   17  error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   388 1   MTP_TEST
Error   18  error C2143: syntax error : missing ')' before 'type'   c:\examples\denfile.c   388 1   MTP_TEST
Error   19  error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   388 1   MTP_TEST
Error   20  error C2065: 'j' : undeclared identifier    c:\examples\denfile.c   388 1   MTP_TEST
Error   22  error C2065: 'j' : undeclared identifier    c:\examples\denfile.c   388 1   MTP_TEST
Error   23  error C2059: syntax error : ')' c:\examples\denfile.c   388 1   MTP_TEST
Error   24  error C2143: syntax error : missing ';' before '{'  c:\examples\denfile.c   389 1   MTP_TEST
Error   25  error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   390 1   MTP_TEST
Error   26  error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   390 1   MTP_TEST
Error   27  error C2143: syntax error : missing ')' before 'type'   c:\examples\denfile.c   390 1   MTP_TEST
Error   28  error C2143: syntax error : missing ';' before 'type'   c:\examples\denfile.c   390 1   MTP_TEST
Error   29  error C2065: 'i' : undeclared identifier    c:\examples\denfile.c   390 1   MTP_TEST
Error   31  error C2065: 'i' : undeclared identifier    c:\examples\denfile.c   390 1   MTP_TEST
Error   32  error C2059: syntax error : ')' c:\examples\denfile.c   390 1   MTP_TEST
Error   33  error C2143: syntax error : missing ';' before '{'  c:\examples\denfile.c   391 1   MTP_TEST
Error   34  error C2065: 'k' : undeclared identifier    c:\examples\denfile.c   392 1   MTP_TEST
Error   35  error C2065: 'j' : undeclared identifier    c:\examples\denfile.c   392 1   MTP_TEST
Error   36  error C2065: 'i' : undeclared identifier    c:\examples\denfile.c   392 1   MTP_TEST
Error   37  error C2065: 'j' : undeclared identifier    c:\examples\denfile.c   392 1   MTP_TEST
Error   38  error C2065: 'i' : undeclared identifier    c:\examples\denfile.c   392 1   MTP_TEST

I’ve been getting these kind of errors all day long. Sometimes the code compiles, while at other time it doesn’t. Its really annoying.

  • 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-14T08:54:32+00:00Added an answer on May 14, 2026 at 8:54 am

    You’re compiling a .c file, which for Microsoft Visual Studio means that you need to be writing C89 (aka C90) code, not C99 code or C++.

    What this means is that you must declare your variables at the start of each block. This means that you can’t do:

    for (int k = 0; ...
    

    You have to declare k at the start of the block and do:

    for (k = 0; ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.