עבור לתוכן
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.

משלוח מערך כפרמטר לפונקציה לא עובד ב ++C

Featured Replies

פורסם

בקוד דלהלן אני מעביר לפונקציה מערך מסוג int ובפונקציה מוסיף לו איבר עם ערך:


void myFunc(int *);
int main()
{
int *myArr;
myFunc(myArr);
return 0;
}

void myFunc(int *myA)
{
myA[0] = 1;
}

התכנית עוברת הידור ללא הודעות שגיאה.

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

מערכת ההפעלה xp מודיעה שהתרחש משהו לא טוב ושואלת אם להודיע על השגיאה למיקרוסופט.

יש למישהו הצעה מוצלחת יותר מזו של ה XP ?

תודה !

פורסם

לא שלחת לה מערך, שלחת לה מצביע למקום אקראי בזיכרון (וכמובן שאסור לך לכתוב לשם)

אתה צריך בתוך ה-main להגדיר את myArr כמערך ולא כמצביע ע"י

int myArr[10];

פורסם
  • מחבר

תודה !

פורסם

או אם אתה מתעקש ללכת עם פויטרים אז כבר:

[pre]

int *arr;

arr = new int[10]

...

your code

...

delete []arr;[/pre]

פורסם

אם תעשה מערך של פויינטרים אז תוכל לעשות מה שרצית(להשוות לNULL).

ארכיון

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

דיונים חדשים

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.