Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1075131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:13:53+00:00 2026-05-16T21:13:53+00:00

Edit: Forget it. it was another part of the code (actually the problem was

  • 0

Edit: Forget it. it was another part of the code (actually the problem was a secondary element. another pointer but not allocated with malloc, just declared, so i think the memory was allocated in another place). the example now can compile.

thanks guys. im sorry for my typos but english isnt my native language(isnt a good escuse but i will try harder) .


hi. i want to pass the some elements (in a struct)to a function but i cannot read the elements in any way(seg faults)

#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>   
#include <netinet/in.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "pcre.h"
#include <arpa/inet.h>
#define BUFFER 1512


typedef struct OCR {
    unsigned long int       ocr;
    struct OCR *         prev;
    struct OCR *         next;
} ip_ocr;


int sending (ip_ocr * tmp) {
    printf("%p\n",tmp); //this outpuut
    printf("%lu",tmp->ocr); // at this point i get a seg fault
    return 0;

}

int main () {
    ip_ocr * list;
    list=malloc(sizeof(ip_ocr));
    list->ocr=1;
    list->next=NULL;
    list->prev=NULL;

    sending(list);


 }    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:13:53+00:00Added an answer on May 16, 2026 at 9:13 pm

    It worked on my machine after a few fixes.

    Include system headers:

    #include <stdio.h>
    #include <stdlib.h>
    

    Add semicolons after these lines:

    printf("%lu",tmp->ocr);
    return 0;
    

    Added (unnecessary) typecast to value returned from malloc:

    list=(ip_ocr*)malloc(sizeof(ip_ocr)); /* oops, not needed */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT Sorry I forgot the most important part here. Each key can have more
Edit (updated question) I have a simple C program: // it is not important
Edit Ok I solved all my problems but one. Is it possible to have
I have a lot of template code. Since bad template code does not throw
I saw a comment on another question (I forget which one) encouraging the asker
I just posted this as part of a reply to a question about the
I need a rule in Apache that redirects not-found CSS files to another location
EDIT: Forgot to remind the reader that I remembered to set templateSettings as follows:
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: I was an idiot. I simply had an image that was vertically long,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.