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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:42:01+00:00 2026-06-16T00:42:01+00:00

I am new in C and apparently I’ve got some problems with understanding all

  • 0

I am new in C and apparently I’ve got some problems with understanding all the memory and pointer things.
So I have the following Java code:

public class Question_10
{
   public static void sortInt(int[] array)
   {
      int top = 0;
      while (top < array.length - 1)
      {
         if (array[top] < array[top + 1])
         {
            top++;
         }
         else
         {
            int temp = array[top];
            array[top] = array[top + 1];
            array[top + 1] = temp;
            if (top > 0)
            {
               top--;
            }
         }
         System.out.println(top);
      }
   }

   public static void main(String[] args)
   {
      int[] arr = {5, 6, 10, 1, 45, 3};

      sortInt(arr);
      System.out.println();
   }

}

Aaand, I’ve done the following:

#include <stdio.h>

void sortInt(int arrayInput[])
{
    int top = 0;
    int arrLen = sizeof(arrayInput)/(sizeof(int);
    while(top < arrLen - 1)
    {
        if(arrayInput[top] < arrayInput[top+1])
        {
            top++;
        }
        else
        {
            int temp = arrayInput[top];
            arrayInput[top] = arrayInput[top + 1];
            arrayInput[top + 1] = temp;
            if(top > 0)
            {
                top--;
            }
        }
        printf("%i", top);
    }
}
void main()
{

    int array[] = {5, 6, 10, 1, 45, 3};
    sortInt(array);
    return 0;
}

Of course I get a lot of errors:

$ gcc Question10.c
Question10.c: In function `sortInt':
Question10.c:6: error: parse error before ';' token
Question10.c: At top level:
Question10.c:16: error: `top' undeclared here (not in a function)
Question10.c:16: warning: data definition has no type or storage class
Question10.c:17: error: `temp' undeclared here (not in a function)
Question10.c:17: warning: data definition has no type or storage class
Question10.c:18: error: parse error before "if"
Question10.c:23: error: parse error before string constant
Question10.c:23: error: conflicting types for 'printf'
Question10.c:23: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
Question10.c:23: error: conflicting types for 'printf'
Question10.c:23: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
Question10.c:23: warning: data definition has no type or storage class
Question10.c: In function `main':
Question10.c:30: warning: `return' with a value, in function returning void
Question10.c:27: warning: return type of 'main' is not `int'
Question10.c:31:2: warning: no newline at end of file
Question10.c: At top level:
Question10.c:16: error: storage size of `arrayInput' isn't known
Question10.c:17: error: storage size of `arrayInput' isn't known

Maybe you could give me any suggestion on what’s wrong and some general guidance will be helpful, because I am really getting lost in these “object” things in C.

  • 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-16T00:42:02+00:00Added an answer on June 16, 2026 at 12:42 am

    There is a syntax error on this line:

    int arrLen = sizeof(arrayInput)/(sizeof(int);

    Try instead with:
    int arrLen = sizeof(arrayInput)/sizeof(int);

    If you start by fixing that then you might solve some of the other problems you have. If not, take one at a time.

    Another error that I can see is that you declared your main method as void main() and you call return 0;. According to the C standard, main() method should return int, so change the declaration.

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

Sidebar

Related Questions

In Java, apparently, String s = foo is preferred over String s = new
New to PHP and MySQL, have heard amazing things about this website from Leo
I'm relatively new to python but think I have a decent enough understanding, except
I'm new to MS Exchange, I've apparently made some error during its installation and
Apparently, the new Objective-C literals have landed into the clang trunk , and thus
I'm very new to all Java related programming. For a school assignment, I've created
My project doesn't seem to be aware of this new constant that's apparently auto-generated
New programmer here, I am trying to understand and break down this code below
Okay...so apparently with the new update in IE8, it starts up with NO add-ons.
I am new to jquery ,I am apparently trying to call a c-sharp function

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.