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

  • Home
  • SEARCH
  • 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 8517497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:43:04+00:00 2026-06-11T05:43:04+00:00

Whats wrong? I’m pretty sure my syntax is correct since it has no warnings.

  • 0

Whats wrong? I’m pretty sure my syntax is correct since it has no warnings. Plus it won’t go past getc(document); I tried fgetc(document); same result. What am I not getting here? (I used printf("$"); to see where it crashes)

char temp[51];
int cntr = 0,listcntr = 0,buffer;
FILE *document;
contact list[MAXCONTACTS];
document = fopen("addressbook.txt","r");
do
{
    for(cntr = 0;cntr < 51; cntr++)
        temp[cntr] = '\0';
    cntr = 0;
    do
    {

        buffer = getc(document);
         printf("$");
        if(buffer != '\t')
            temp[cntr] = buffer;
        ++cntr; 
    }while(buffer != '\t'&& buffer != EOF);
list[listcntr].name = temp;
  • 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-06-11T05:43:05+00:00Added an answer on June 11, 2026 at 5:43 am

    OK I modified your code a little and added a couple of checks, maybe it will be enough.

    char temp[51];
    int listcntr = 0,buffer;
    contact list[MAXCONTACTS];
    FILE *document = fopen("addressbook.txt","r");
    
    if (NULL == document){
        //exit here
    }
    
    for(int i = 0;i < 51; i++){
        temp[i] = '\0';
    }
    
    int cntr = 0;
    for (int cntr=0; cntr < 51 && !feof(document); cntr++){
        buffer = getc(document);
        if (buffer == '\t'){
            break;
        }
        temp[cntr] = buffer;
    }
    
    if(listcntr < MAXCONTACTS){
        // you should probably copy temp here
        list[listcntr].name = temp;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has been asked before but I still cannot figure whats wrong for
I am not sure how to find out more about whats wrong with my
Whats wrong in here? $(document).ready(function(){ $(window).load(function(){$(#welcome).fadeIn(2000); }) setTimeout(function(){ $('div#welcome').fadeOut(2000); }, 4000); setTimeout(function(){ $('div#content').fadeIn(2000); },
whats wrong with my syntax? CREATE TRIGGER db_dhruniversity.trigger1 AFTER INSERT ON jos_dhruprofile FOR EACH
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I'm not sure whats wrong with the program below, but it doesn't print each
Not sure whats wrong here the error report says line 9, but when I
Whats wrong wrong with this query please correct me on this syntactcally it's going
Whats wrong with my code? Why does .atrr() show empty? Thanks $(document).ready(function(){ $('#push').click(function(){ alert($('#push2').attr('href').val);
I'm not sure whats wrong with this it says incompatible implicit built in func

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.