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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:33:46+00:00 2026-06-04T15:33:46+00:00

I just start to study functions in C and this stopped me. I want

  • 0

I just start to study functions in C and this stopped me. I want to write a function that searches for an element in a vector of SIZE elements. Here’s the code:

#include <stdio.h>
#define SIZE 10

int find(int vet[], int SIZE, int elem);

int main()
{
    int vett[SIZE] = {1, 59, 16, 0, 7, 32, 78, 90, 83, 14};
    int elem;

    printf ("Imput the element to find: ");
    scanf  ("%d", &elem);

    find(vett[SIZE], SIZE, elem);

    if (find == 1)
        printf ("\nI find the element!");
    else if (find == 2)
        printf ("\nI did not find the element!");

    return 0;
}

int find(int vett[], int SIZE, int elem)
{
    int i;
    int flag = 0;

    for (i = 0; i < SIZE; i++)
        if (vett[i] == elem)
            flag = 1;

    if (flag == 1)
        return 1;
    else
        return 2;
}

Why does Code::Blocks say to me:

|4|error: expected ';', ',' or ')' before numeric constant| 
||In function 'main':| |8|error: expected ']' before ';' token| 
|14|error: 'vett' undeclared (first use in this function)| 
|14|error: (Each undeclared identifier is reported only once| 
|14|error: for each function it appears in.)| 
|14|error: expected ']' before ';' token|
|14|error: expected ')' before ';' token| 
|16|warning: comparison between pointer and integer|

|18|warning: comparison between pointer and integer|
|24|error: expected ';', ',' or ')' before numeric constant|
||=== Build finished: 8 errors, 2 warnings ===|

What did I do wrong?

  • 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-06-04T15:33:48+00:00Added an answer on June 4, 2026 at 3:33 pm

    If you are using SIZE as a constant and then you don’t need to pass it to the function:

    int find(int vet[], int elem);
    

    If you want the function to be generic, and then define its prototype like this:

    int find(int vet[], int size, int elem);
    

    and call it like this:

    find(vett, SIZE, elem);
    

    and write it like this:

    int find(int vett[], int size, int elem)
    {
        int i;
        int flag = 0;
    
        for (i = 0; i < size; i++)
            if (vett[i] == elem)
                flag = 1;
    
        if (flag == 1)
            return 1;
        else
            return 2;
    }
    

    ==EDIT==
    regarding the question from the comment:
    the find is a pointer to a function, it’s not holding the return value. you can use it in one of the following ways:
    -1-

    int answer = find(vett[size], size, elem);
    
    if (answer == 1)
        printf ("\nI find the element!");
    else if (find == 2)
        printf ("\nI did not find the element!");
    

    -2-

    if (find(vett[size], size, elem) == 1)
        printf ("\nI find the element!");
    else if (find == 2)
        printf ("\nI did not find the element!");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just start learning to write web services yesterday, kinda fascinating. I created an
I just start learning WPF, is that possible I can create an IE toolbar
I'm not sure exactly how to explain this, so I'll just start with an
I want to load My ACL plugin to the application, and just start working
I wrote simple class that on the start it just increase the value of
I'll just start by presenting code that doesn't behave like it should. As it's
I just start a project where I need to have a WCF services that
I just start study DI (I'm working on WPF/Silverlight but I have a plan
Hello I just start to develop php what I want to do is to
I've just start playing about with jQuery and want to place the results of

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.