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

  • Home
  • SEARCH
  • 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 809365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:43:03+00:00 2026-05-15T00:43:03+00:00

We are programming a ST269 microcontroller which has two IR distance sensors. To calibrate

  • 0

We are programming a ST269 microcontroller which has two IR distance sensors. To calibrate these sensors we made one table for each sensor with the distance we measured and the corresponding value we get from the ADC.

Now we want to use one function to approximate the values in between. So we defined two two-dimensional arrays (one for each sensor) as global variables. In our function we then want to copy the one array we want to work with to a working array and approximate our values.

So here’s the code:

...

unsigned int ir_werte_re[][] = {
    {8,553}, 
    ...
    {83,133}
};

unsigned int ir_werte_li[][] = {
    {8,566}, 
    ...
    {83,147}
};

...

unsigned int geradenaproximation(unsigned int messwert, unsigned int seite)
{
    unsigned int working_array[16][16];
    unsigned int i = 0;

    if (seite == 0) {
        for (i = 0; i < sizeof(working_array); i++) {
            working_array[i][0] = ir_werte_li[i][0];
            i++;
        }
    }
    else {
        for (i = 0; i < sizeof(working_array); i++) {
            working_array[i][0] = ir_werte_re[i][0];
            i++;
        }
    }

    i = 0;
    unsigned int y1 = 0;
    unsigned int x1 = 0;
    ...
}

This code is in a file called sensor.c. We didn’t write anything about our global arrays in the sensor.h should we? The sensor.h of course is included in our main.c and there the function is called.

We also tried to copy the arrays via

memcpy(working_array, ir_werte_li, sizeof(working_array));

And in every way we do this we get a

syntax error near unsigned

in the line where we’re declaring

unsigned int y1 = 0;

and I’m pretty sure that there is no syntax error in this line : )

The last time I spend coding in C is a few years away so I’m not sure if the way we try to do this is good. Perhaps we can solve this by using a pointer instead of really copying the array or something. So please help me out I’ll appreciate your bits on this.

  • 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-15T00:43:04+00:00Added an answer on May 15, 2026 at 12:43 am

    In C (pre-C99), all variable definitions must appear at the top of the current block scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning on my own about writing an interpreter for a programming language,

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.