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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:12:38+00:00 2026-05-28T03:12:38+00:00

I have the following code of declarations: struct coord { int x; int y;

  • 0

I have the following code of declarations:

struct coord {
int x;
int y;
}
void rotateFig(struct coord[10][10]);

I need to implement rotateFig.
I tried to start with following:

void rotateFig(struct coord[10][10] c)
{
   //code
}

I can`t compile it – probaly the way I transfer c in the function definition is incorrect .How should I transfer c using given signature.
Thank you

  • 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-28T03:12:39+00:00Added an answer on May 28, 2026 at 3:12 am

    struct coord is a type and c is a variable of type struct coord which can hold 10 X 10 struct coord elements.

    So it should be as follows

    void rotateFig(struct coord c[10][10])
    

    One thing to note when working with multi-dimension array in C is that it cannot be return back from a function. For details, read this. So its not advised to use the above format as C by default passes arguments by value and not by address.

    So as @Mr.TAMER mentioned in his answer, you should use the following

    void rotateFig(struct coord** c, int d1, int d2)
    

    OTOH, you can use the following rotate code for your reference! It rotates a 2d array to 90 degrees!

    #include <stdio.h>
    
    #define N 10 
    int matrix[N][N];
    
    void display()
    {
        int i, j;
    
        printf("\n");
        for (i=0; i<N; i++) {
            for (j=0; j<N; j++) 
                printf("%3d", matrix[i][j]);
            printf("\n");
        }
        printf("\n");
    
        return;
    }
    
    int main()
    {
        int i, j, val = 1;
        int layer, first, last, offset, top;
    
        for (i=0; i<N; i++)
            for (j=0; j<N; j++)
                matrix[i][j] = val++;
    
        display();
    
        for (layer = 0; layer < N/2 ; layer++) {
            first = layer;
            last = N - layer - 1;
            for (i=first; i< last ; i++) {
                offset = i - first;
                top = matrix[first][i];
    
                matrix[first][i] = matrix[last-offset][first];
                matrix[last-offset][first] = matrix[last][last-offset];
                matrix[last][last-offset] = matrix[i][last];
                matrix[i][last] = top;
            }
        }
    
        display();
        return 0;
    }
    

    Hope this helps!

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

Sidebar

Related Questions

I have following Code Block Which I tried to optimize in the Optimized section
I have following code snippet that i use to compile class at the run
I have the following struct declaration and typedef in my code: struct blockHeaderStruct {
I have the following code but I am getting the following compile errors: Attribute
I have the following code (include-guards omitted for simplicity's sake): = foo.hpp = struct
I have written the following C99 code and was wondering about the struct declaration.
I have the following code: #include <queue> struct Job { }; queue<Job> _jobQueue; But
I have the following code: static int gridX = 40; static int gridY =
I have the following code (exerpt): <fx:Declarations> <fx:Array id=ribbonTabs> <fx:String>Home</fx:String> <fx:String>Help</fx:String> </fx:Array> </fx:Declarations> <cx:RibbonBar
I have the following struct: public struct Declarations { public const string SchemaVersion =

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.