עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

STRUCT, עוד פעם..

Featured Replies

פורסם
  • מחבר

int main()
{
vec v={0};
int i;
system ("cls");
for(i=0;i<9;++i)
setCell(&v,i,5);
for(i=0;i<9;++i)
printf("%d ,",getCell(v,i));
getchar();
return 0;
}

#include "vec.h"

int getCell(vec v, int index)
{
return(v.vector[index]);
}

int setCell(vec *v, int index, int num)
{
(*v).vector[index]=num;
return(1);
}

struct vecc
{
int vector[9];
};

typedef struct vecc vec;

int getCell(vec v, int index);
int setCell(vec *v, int index, int num);

תראו הודיעו לי שאני יכול לעבוד עם TYPEDEF במקום הSTRUCT אם אני רוצה.

יעני משהו כזה

typedef int vec[9];

רק אני לא מסתדר עם זה בכל הקטע שם עוד TYPEDEF עבודה עם זה בפונקציות...

זה עדיף לעשות הסבה?

פורסם

typedef זה פשוט לתת שם נרדף לטיפוס. ברגע שעשית

typedef int vec[9];

זה אומר שבכל מקום שבו אתה רוצה לרשום

int x[9]

אתה יכול לרשום פשוט

vec x;

ואין בעיה להצהיר ככה על משתנה, או כפרמטר לפונקציה.

כמובן שכמו כל משתנה, אתה יכול ליצור מצביע אליו וכו' (הטיפוס של המצביע יהיה *vec).

פורסם
  • מחבר

מה רע פה?

typedef mat queb[9];

mat getMat(queb t, int deep);

הרי שאני מחזיר את MAT זה כאילו אני רושם איזה INT** לא?

פורסם

מערך הוא לא lval ולכן אינך יכול להחזיר מערך.

אתה יכול להחזיר מצביע(queb*).

פורסם
  • מחבר

סבבה אני אשנה אבל יש לי שאלה, בהנחה שהייתי משתמש במערכים רגילים ולא TYPEDEF / STRUCT או לא משנה מה

שני השורות האלה לא שקולות

mat getMat(queb t, int deep);

int** getMat(queb t, int deep);

ולמשהו אחר

אני יכול לשלוח את MAT לפונקציה או שאני צריך גם לשלוח את הכתובת ולקבל מצביע..?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.