הפרת גישה - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

הפרת גישה


rachelig555
 Share

Recommended Posts

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

Unhandled exception at 0x55AF2C23 (ucrtbased.dll) in linux_c_1.exe: 0xC0000005: Access violation writing location 0x009D7BF4.

 

 

חדשה בתחום אשמח לעזרה

 


#include<stdio.h>
#include <string.h>
#include <stdlib.h>
char** stringTowords(char *setOfWords) {   
    if (setOfWords == NULL)
        return NULL;
    int counterWords = 0,w=0;
    //printf("%s\n", setOfWords);
    char* copy =(char*)malloc(sizeof(char)*strlen(setOfWords+1)) ;//הקצאת לצורך העתקת המחרוזת המקורית
    strcpy(copy,setOfWords);
    //printf("%s\n", copy);
    //printf("%s\n", setOfWords);
    
    char *cWords = strtok(setOfWords," ");
    //printf("%s\n",cWords);
    while (cWords != NULL) {
        //printf("%s\n", token);
        counterWords++;
        cWords = strtok(NULL," ");
    }

    /*while (count != NULL) {
        //printf("%s\n", token);
        counterWords++;
        count = strtok(NULL," ");
    }
    printf("%d\n", counterWords);
    
    char**words = (char**)malloc((counterWords + 1)*(sizeof(char*)));
    if (words == NULL) {
        exit(0);
    }
    (" "char*word= strtok(setOfWords, ;  בשורה הזו מופיע השגיאההה
    while (word != NULL) {
        words[w] = (char*)malloc((strlen(word)+1)*sizeof(char));

    }*/
    
}


int main() {
    int x,i=0;

"char * setOfWords= "word hello   echo;
stringTowords(setOfWords);


scanf("%d",&x);
}
 

קישור לתוכן
שתף באתרים אחרים

  • 1 חודש מאוחר יותר...

הצטרפ/י לדיון

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

אורח
הוסף תגובה

×   התוכן שהודבק הוא עם עיצוב.   הסר עיצוב

  Only 75 emoji are allowed.

×   הקישור שלך הוטמע אוטומטית.   הצג כקישור רגיל

×   התוכן הקודם שלך שוחזר אוטומטית.   נקה הכל

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
  • צור חדש...