עבור לתוכן

הפרת גישה

Featured Replies

פורסם

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

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 חודש מאוחר יותר...
פורסם

הקוד שלך מפורמט זוועה. בבקשה תכניסי קוד ע"י הלחצן image.png.ea117211285413c48383bcb8d3f74177.png בתפריט.

ארכיון

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

דיונים חדשים