פורסם 2011 ביוני 1414 שנים שלום לכולם, אשמח לעזרתכם, אני כותבת פונקציה שמקבלת מחרוזת(str) ומחסן מחרוזת (storage), ואני רוצה שתמצא לי את המחרוזת האחרונה(שנכנסה אחרונה למחסן) במחסן שלא מכילה את str. אני משתמשת בפונקצייה strstr אבל בכל קלט היא מחזירה לי NULL. מצורפת הפונקצייה אודה על כל עזרה // finds the last line entered to storage the dosent contains str and prints it if found// if didnt find then prints an error messagebool 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;}
פורסם 2011 ביוני 1414 שנים מה התוכן של str ומה התוכן של storage? את מי את מחפשת בתוך מי? שימי לש ש-(strstr(a,b מחפשת את b בתוך a, ולא להיפך.
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.