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 8639033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:53:46+00:00 2026-06-12T10:53:46+00:00

hi guys im trying to transfer an older code from C to C++ for

  • 0

hi guys im trying to transfer an older code from C to C++ for an assignment…. i have to implement a linked list by hand so I cannot use STL containers otherwise i’d already be done with this….

here’s my linked list:

#include <iostream> 
#include <string>
#include <fstream>
using namespace std;


struct Video { 
char video_name[1024];      //  video name
int ranking;                // Number of viewer hits
char url[1024];             //  URL
Video *next;  // pointer to Video structure
}  *head = NULL;        // EMPTY linked list

here is the read-in code:

void load()
{
struct Video *temp;
temp = (Video*)malloc(sizeof(Video)); //allocate space for node 
temp = head;
ifstream myfile ("Ranking.dbm");
if (myfile.is_open())
{
    string line;
    while ( myfile.good() )
    {

        myfile.getline(temp->video_name,1024);
        myfile >> temp->ranking;
        getline(myfile, line); // need to skip 'ranking's
                                // unread new-line
        myfile.getline(temp->url,1024);
        temp = temp->next; 

    }
    head = NULL;
    myfile.close();
}

else cout << "Unable to open file"; 

return ;

}

it is reading from a text file Ranking.dbm which looks like this:

bagheera
20
bagheera.com
sushi
60
sushi.com
wicket
99
wicket.com
teek
100
teek.com

basically each set of 3 lines should load into a Video structure which will be a new node in the linked list.

due to circustances beyond my control i am using XCode for this project. my question is why am I getting this error. I thought EXC_BAD_ACCESS was primarily an Objective-C error…?

  • 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-12T10:53:47+00:00Added an answer on June 12, 2026 at 10:53 am

    In your load() function, you allocate a single node, read data to fill in the node, then assign temp = temp->next. However, temp->next is not initialized, so likely points to a random address.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guys I'm trying the code samples from zend frameworks site on how to
Hey guys I am trying to authenticate my solution from another website I have
Hey Guys I'm trying to get the Railscasts source code from github. when I'm
Hi Guys i'm trying to let my Screen blink a morse code out using
hello guys I am trying to extract all the anchor links from aol but
hello guys i am trying to print title from a set of urls in
Hi guys Im trying to make a drop-down list of countries and when the
hey guys im trying to do a SELECT Statement from a local SQLDB so
Guys I'm trying to implement deletion algorithm for a Red Black tree and I'm
Hey guys I'm trying to see where my pairs of keys stop, I have

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.