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

פורסם

שלום לכולם מי שיוכל לעזור לי להבין את זה אני אשמח מאוד

בתרגיל אני צריך לכתוב פונקצייה שבודקת אם מחרוזת אחת היא הסוף של השנייה לדוגמא ASDFG וDFG.

לא הבנתי איך אני מקדם את הכתובת בפויינטר ואיך אני קורא לפונקצייה מהתוכנית הראשית (עם & או בלי או מה שלא יהיה)

זה הקוד של הפונקצייה





#include<iostream>
#include<string.h>
using namespace std;


void strend(char* s, char* t)
{
int len,len2,cheakfrom,i;
len=strlen(s);
len2=strlen(t);
cheakfrom=len-len2;
for(i=(*s+cheakfrom);i<len;i++ )
if((*s+cheakfrom)==*t)
cheakfrom++;
*t++;
if(cheakfrom == len)
cout<<"ok\n";
else
cout<<"no\n";
}


פורסם
  • מחבר

ואם מישהו יכול גם על הרך להסביר לי פה איך אני משתמש במערכים ובפויינטרים כי לא ממש הבנתי את החלק הזה

פורסם

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

t[index] = 'a';

דבר שני, שים לב שכאשר אינך פותח סוגריים מסולסלות, אינך מייצר בלוק, ולכן רק המשפט הראשון של הלולאה או ההתניה יחשב כשייך לה..

לדוגמא אצלך בקוד:

*t++;

לא יהיה שייך ל for וגם לא ל if...

מה שהופך את הקוד שלך ללא נכון ובטח לא מה שאתה התכוונת.

ארכיון

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

דיונים חדשים

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.