{"id":8835,"date":"2022-09-15T19:54:32","date_gmt":"2022-09-15T14:24:32","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/"},"modified":"2022-09-15T19:54:32","modified_gmt":"2022-09-15T14:24:32","slug":"solved-need-help-i-get-segmentation-fault-in-program-in-c","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/","title":{"rendered":"[Solved] Need help i get segmentation fault in program in C"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-41657981\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"41657981\" data-parentid=\"41657774\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>A proper implementation of getfiles (gets all the files in a directory in a dynamic array) and provides a deallocator:<\/p>\n<pre><code>#include &lt;stdio.h&gt;\n#include &lt;dirent.h&gt;\n#include &lt;string.h&gt;\n#include &lt;stdlib.h&gt;\n\n\/* returns a NULL terminated array of files in directory *\/\n\nchar **getfilelist(const char *dirname) {\n        DIR *dp;\n        char **entries = NULL;\n        struct dirent *entry;\n        off_t index = 0;\n\n        dp = opendir(dirname);\n        if (!dp) {\n                perror(dirname);\n                return NULL;\n        }\n\n        while((entry = readdir(dp)) != NULL) {\n                \/* increase entries array size by one pointer-size *\/\n                entries = realloc(entries, (1+index)*sizeof(char *));\n\n                \/* strdup returns a newly allocated duplicate of a string that \n                 * you must free yourself\n                 *\/\n                entries[index] = strdup(entry-&gt;d_name);\n                index++;\n        }\n\n        \/* need one more entry for NULL termination *\/\n        entries = realloc(entries, (1+index)*sizeof(char *));\n        entries[index] = NULL;\n\n        return entries;\n}\n\nvoid putfilelist(char **entries) {\n        char **p;\n        if(!entries)\n                return;\n        for(p = entries; *p !=NULL ; p++) {\n                free(*p); \/* free all the strdups *\/\n        }\n        free(entries); \/* free the array of pointers *\/\n}\n<\/code><\/pre>\n<p>An example of how you could use it:<\/p>\n<pre><code>int main(int argc, char **argv) {\n        char **p, **entries;\n        char *dir = (argc == 1 ? \".\" : argv[1]);\n        entries = getfilelist(dir);\n        for (p = entries; p &amp;&amp; *p; p++) {\n                printf(\"%s\\n\", *p);\n        }\n        putfilelist(entries);\n}\n<\/code><\/pre>\n<h1>Updated solution,<\/h1>\n<p>In order to implement your solution without using any of the library code, and keep it to system calls, here is an example that implements everything that the above example does, without relying on higher-level library calls.<\/p>\n<h2>Note<\/h2>\n<p>The bottom functions are the same as the above example.<\/p>\n<pre><code>\/*\n * A partially low-level implementation using a direct system calls\n * and internal memory management \n * \n * This is an opinionated (linux only) implementation of OP \n *\n * linux headers are only included for some of the constants and \n * where it would be trivial to re-implement system calls (e.g. open, write etc.)\n * which I am too lazy to do in this example.\n *\n *\/\n\n#define NDEBUG\n\n#include &lt;stdarg.h&gt;\n#include &lt;unistd.h&gt;\n#include &lt;sys\/syscall.h&gt;\n#include &lt;linux\/fcntl.h&gt;\n#include &lt;linux\/unistd.h&gt;\n\n\/* replace this macro with your own error handling messages *\/\n#define handle_error(msg) \\\n    do { my_fdputs(2, msg); my_exit(-127); } while (0)\n\n#if !defined(NDEBUG)\n#define assert(x) do { int __rv = (x); if(!__rv) { my_fdprintf(2, \"assertion failed %s\\n\", #x); my_exit(__rv); } } while(0)\n#else \n#define assert(x) do {} while(0)\n#endif\n\n\n\n\/* returns a NULL terminated array of files in directory *\/\n\/* low-level list builder using getdents *\/\n\nvoid my_exit(int x)\n{\n    syscall(SYS_exit_group, x);\n}\n\n\/* a trivial malloc \/ realloc \/ free *\/\n\n\/* simple linked list memory accounting *\/\nstruct memblock {\n    struct memblock *next;\n    size_t size;\n    int free; \/* flag *\/\n    int magic; \/* canary value for debugging *\/\n};\n\n#define METASIZE sizeof(struct memblock)\n\nvoid *global_base = NULL; \n\nstruct memblock *find_free_block(struct memblock **last, size_t size)\n{\n    struct memblock *current = global_base;\n    while(current &amp;&amp; !(current-&gt;free &amp;&amp; current-&gt;size &gt;= size)) {\n        *last = current;\n        current = current-&gt;next;\n    }\n    return current;\n}\n\n\n\/*\n * instead of using sbrk, we should really use mmap on newer\n * linux kernels and do better accounting, however this is a\n * simple example to get you started\n *\/\n\nstruct memblock *request_space(struct memblock *last, size_t size)\n{\n    struct memblock *block;\n    void *request;\n\n    block = sbrk(0); \/* get current program break *\/\n    request = sbrk(size + METASIZE);\n    assert((void *)block == request);\n    if(request  == (void *)-1) {\n        return NULL;\n    }\n\n    if(last) {\n        last-&gt;next = block;\n    }\n    block-&gt;size = size;\n    block-&gt;next = NULL;\n    block-&gt;free = 0;\n    block-&gt;magic = 0x12345678;\n\n    return block;\n}\n\nstruct memblock *get_memblock_ptr(void *ptr)\n{\n    return (struct memblock *)ptr - 1;\n}\n\n\/* a simple memcpy, can be optimized by taking alignment into account *\/\n\nvoid *my_memcpy(void *dst, void *src, size_t len)\n{\n    size_t i;\n    char *d = dst;\n    const char *s = src;\n    struct memblock *bd, *bs;\n    bd = get_memblock_ptr(dst);\n    for(i = 0; i &lt; len; i++) {\n        d[i] = s[i];\n    }\n    return dst;\n}\n\n\/* now to implement malloc *\/\nvoid *my_malloc(size_t size)\n{\n    struct memblock *block;\n\n    if(size == 0)\n        return NULL;\n\n    if(!global_base) {\n        block = request_space(NULL, size);\n        if(!block)\n            return NULL;\n        global_base = block;\n    }\n    else {\n        struct memblock *last = global_base;\n        block = find_free_block(&amp;last, size);\n        if(!block) {\n            block = request_space(last, size);\n            if(!block) {\n                return NULL;\n            }\n        }\n        else {\n            block-&gt;free = 0;\n            block-&gt;magic = 0x77777777;\n        }\n    }\n\n    return (block+1);\n}\n\nvoid my_free(void *ptr)\n{\n\n    struct memblock *block;\n    if (!ptr)\n        return;\n\n    block = get_memblock_ptr(ptr);\n    assert(block-&gt;free == 0);\n    assert(block-&gt;magic == 0x77777777 || block-&gt;magic == 0x12345678);\n    block-&gt;free = 1;\n    block-&gt;magic = 0x55555555;\n}\n\n\nvoid *my_realloc(void *ptr, size_t size)\n{\n    struct memblock *block;\n    void *newptr;\n\n    if(!ptr) \n        return my_malloc(size);\n\n    block = get_memblock_ptr(ptr);\n    if(block-&gt;size &gt;= size)\n        return ptr;\n\n    newptr = my_malloc(size);\n    if(!newptr)  {\n        return NULL;\n    }\n\n    my_memcpy(newptr, ptr, block-&gt;size);\n    my_free(ptr);\n    return newptr;\n}\n\n\n\/* trivial string functions *\/\n\nsize_t my_strlen(const char *src) {\n    size_t len = 0;\n    while(src[len])\n        len++;\n    return len;\n}\n\nchar *my_strdup(const char *src)\n{\n    char *dst;\n    char *p;\n    size_t len = 0, i;\n    len = my_strlen(src);\n\n\n    dst = my_malloc(1+len);\n    if(!dst) \n        return NULL;\n\n    for(i = 0; i &lt; len; i++) {\n        dst[i] = src[i];\n    }\n    dst[i] = 0;\n    return dst;\n}\n\n\n\/* trivial output functions *\/\n\nmy_fdputs(int fd, const char *str)\n{\n    return write(fd, str, my_strlen(str));\n}\n\nint my_fdputc(int fd, char c)\n{\n    return write(fd, &amp;c, sizeof(char));\n}\n\n\/* a very limited implementation of printf *\/\nint my_fdvprintf(int fd, const char *fmt, va_list ap)\n{\n    const char *p;\n    int count = 0;\n    for(p = fmt; p &amp;&amp; *p; p++ ) {\n        if(*p == '%')  {\n            p++;\n            switch(*p) {\n            case 's':\n                count += my_fdputs(fd, va_arg(ap, char *));\n                break;\n            case '%':\n                count += my_fdputc(fd, '%');\n                break;\n            default: \n#ifndef NDEBUG\n                my_fdputs(2, \"warning: unimplemented printf format specifier %\");\n                my_fdputc(2, *p);\n                my_fdputc(2, '\\n');\n#endif\n                break;\n            }\n        }\n        else {\n            my_fdputc(fd, *p);\n        }\n    }\n    return count;\n}\n\nint my_fdprintf(int fd, const char *fmt, ...)\n{\n    int rv;\n    va_list ap;\n    va_start(ap, fmt);\n    rv = my_fdvprintf(fd, fmt, ap);\n    va_end(ap);\n    return rv;\n}\n\n\n\/* wrapper to linux getdents directory entry call *\/    \n\/* linux dirent structure *\/\nstruct linux_dirent {\n    long           d_ino;\n    off_t          d_off;\n    unsigned short d_reclen;\n    char           d_name[];\n};\n\n\/* system call wrapper *\/\nint getdents(int fd, void *buf, size_t bufsize)\n{\n    return syscall(SYS_getdents, fd, buf, bufsize);\n}\n\n\n\/* reimplement getfilelist using our getdents *\/    \n#define BUF_SIZE 1024\nchar **getfilelist(const char *dirname) {\n    int fd, nread;\n        char **entries = NULL;\n        off_t index = 0;\n\n    char buf[BUF_SIZE];\n    struct linux_dirent *d;\n    int bpos;\n\n\n    \/* O_DIRECTORY since kernel 2.1 *\/\n        fd = open(dirname, O_DIRECTORY|O_RDONLY);\n\n        if (fd &lt; 0) {\n                handle_error(dirname);\n        }\n\n    for(;;) {\n        nread = getdents(fd, buf, BUF_SIZE);\n        if (nread == -1)\n            handle_error(\"getdents\");\n\n        if (nread == 0)\n            break;\n\n        for (bpos = 0; bpos &lt; nread;) {\n            d = (struct linux_dirent *) (buf + bpos);\n            entries = my_realloc(entries, (1+index) * sizeof(char *));\n            entries[index++] = my_strdup(d-&gt;d_name);\n            bpos += d-&gt;d_reclen;\n                }\n    }\n\n       \/* need one more entry for NULL termination *\/\n        entries = my_realloc(entries, (1+index)*sizeof(char *));\n        entries[index] = NULL;\n\n    close(fd);\n\n    return entries;\n}\n\nvoid putfilelist(char **entries) {\n        char **p;\n        if(!entries)\n                return;\n        for(p = entries; *p !=NULL ; p++) {\n                my_free(*p); \/* free all the strdups *\/\n        }\n        my_free(entries); \/* free the array of pointers *\/\n}\n\n\nint main(int argc, char **argv) {\n        char **p, **entries;\n        char *dir = (argc == 1 ? \".\" : argv[1]);\n        entries = getfilelist(dir);\n        for (p = entries; p &amp;&amp; *p; p++) {\n                my_fdprintf(1, \"%s\\n\", *p);\n        }\n        putfilelist(entries);\n}\n<\/code><\/pre>\n<p>Hope you enjoy<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">5<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Need help i get segmentation fault in program in C <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] A proper implementation of getfiles (gets all the files in a directory in a dynamic array) and provides a deallocator: #include &lt;stdio.h&gt; #include &lt;dirent.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; \/* returns a NULL terminated array of files in directory *\/ char **getfilelist(const char *dirname) { DIR *dp; char **entries = NULL; struct dirent *entry; off_t &#8230; <a title=\"[Solved] Need help i get segmentation fault in program in C\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\" aria-label=\"More on [Solved] Need help i get segmentation fault in program in C\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[324,1187],"class_list":["post-8835","post","type-post","status-publish","format-standard","hentry","category-solved","tag-c","tag-segmentation-fault"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Need help i get segmentation fault in program in C - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Need help i get segmentation fault in program in C - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] A proper implementation of getfiles (gets all the files in a directory in a dynamic array) and provides a deallocator: #include &lt;stdio.h&gt; #include &lt;dirent.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; \/* returns a NULL terminated array of files in directory *\/ char **getfilelist(const char *dirname) { DIR *dp; char **entries = NULL; struct dirent *entry; off_t ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-15T14:24:32+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Need help i get segmentation fault in program in C\",\"datePublished\":\"2022-09-15T14:24:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\"},\"wordCount\":105,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"c++\",\"segmentation-fault\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\",\"name\":\"[Solved] Need help i get segmentation fault in program in C - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-15T14:24:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Need help i get segmentation fault in program in C\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Need help i get segmentation fault in program in C - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Need help i get segmentation fault in program in C - JassWeb","og_description":"[ad_1] A proper implementation of getfiles (gets all the files in a directory in a dynamic array) and provides a deallocator: #include &lt;stdio.h&gt; #include &lt;dirent.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; \/* returns a NULL terminated array of files in directory *\/ char **getfilelist(const char *dirname) { DIR *dp; char **entries = NULL; struct dirent *entry; off_t ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/","og_site_name":"JassWeb","article_published_time":"2022-09-15T14:24:32+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Need help i get segmentation fault in program in C","datePublished":"2022-09-15T14:24:32+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/"},"wordCount":105,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["c++","segmentation-fault"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/","url":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/","name":"[Solved] Need help i get segmentation fault in program in C - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-15T14:24:32+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-need-help-i-get-segmentation-fault-in-program-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Need help i get segmentation fault in program in C"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=8835"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8835\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=8835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=8835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=8835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}