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

שימוש בפונקציית strstr ב C

Featured Replies

פורסם

שלום לכולם,

אשמח לעזרתכם,

אני כותבת פונקציה שמקבלת מחרוזת(str) ומחסן מחרוזת (storage), ואני רוצה שתמצא לי את המחרוזת האחרונה(שנכנסה אחרונה למחסן) במחסן שלא מכילה את str.

אני משתמשת בפונקצייה strstr אבל בכל קלט היא מחזירה לי NULL.

מצורפת הפונקצייה

אודה על כל עזרה :xyxthumbs:



// finds the last line entered to storage the dosent contains str and prints it if found
// if didnt find then prints an error message
bool lastLineWithNoStr(char **storage,int size, int nextLine,char *str)
{
int i=0;
bool strNFound=FALSE;
char * g;
while(i<size && strNFound==FALSE)
{
g=strstr(str,storage[(nextLine-i-1)%size]);
//g=strstr("bbcb","bc");
if(g==NULL)
//if(strstr(str,storage[(nextLine-i-1)%size])==NULL)// str isnt in line number (nextLine -1)
{
printf("%s\n",storage[(nextLine-i-1)%size]);
strNFound=TRUE;
return TRUE;
}
else// str is in line number (nextLine-1)
i++;
/*
{
printf("%s\n",storage[(pLastLine-i)%size]);
strFound=TRUE;
return TRUE;
}*/

}
printf("There is no lines without the string %s\n",str+2);
return FALSE;
}

פורסם

מה התוכן של str ומה התוכן של storage? את מי את מחפשת בתוך מי? שימי לש ש-(strstr(a,b מחפשת את b בתוך a, ולא להיפך.

פורסם
  • מחבר

וואלה, פדיחה לומר אבל זו באמת היתה הבעיה.

תודה שניצל :xyxthumbs:

ארכיון

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

דיונים חדשים

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.