I keep getting a fatal error while trying to load a file.

Posted on 2011-03-16
Last Modified: 2012-05-11
I keep getting some errors while trying to load my file into a structure and I don't understand what they are for or where I'm making the mistake. These are the erros I'm getting also. Any help would be greatly appreciated :)

1>------ Build started: Project: practice, Configuration: Debug Win32 ------
1>warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>practice.obj : error LNK2019: unresolved external symbol "void __cdecl loadFile(struct _iobuf *,struct myRecords *,char * const)" (?loadFile@@YAXPAU_iobuf@@PAUmyRecords@@QAD@Z) referenced in function _main
1>C:\Users\Theresa\Desktop\practice\Debug\practice.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

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

struct customers
	int cust_id;
	char cust_name[19];
	char state[3];
	char discount;
	double balance_due;
	int order_out;

struct myRecords
	customers rec[10];

using namespace std;

//functions go here
void loadFile(FILE *, struct myRecords *, char[]);

int main()
{	char buffer[50];
	int counter = 0;

	myRecords table, *point_table;
	point_table = &table;

	FILE *fp;
	fp = fopen("ASSIGNV1.DAT", "r");
	if (fp == NULL)
		printf ("Error opening file! ");
		loadFile(fp, point_table, buffer);


void loadFile(FILE *fp, struct myRecords table, char buffer[])
	int counter = 0;
		fgets(buffer, 20, fp);
		table.rec[counter].cust_id = atoi(buffer);
		fgets(table.rec[counter].cust_name, 20, fp);
		fgets(table.rec[counter].state, 20, fp);
		fgets(buffer, 20, fp);
		table.rec[counter].discount = buffer[0];
		fgets(buffer, 20, fp);
		table.rec[counter].balance_due = atof(buffer);
		fgets(buffer, 20, fp);
		table.rec[counter].order_out = atoi(buffer);

Open in new window

Question by:reesee324
LVL 31

Accepted Solution

Zoppo earned 500 total points
ID: 35149766
Hi reesee324,

IMO the problem is the declaration and implementation of 'loadFile' are different.

First you declare it with second paramter is of type 'struct myRecords*', but in the implementation you declare the second parameter to be of type 'struct myRecords'. Therefor the linker doesn't find the function needed.

You have to change the 'struct myRecords table' to i.e. 'struct myRecords* table' and modify the kind how this param is accessed in the function.

Hope that helps,


Author Comment

ID: 35149941
Okay thanks! Sometimes you just need a new set of eyes :)

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
libcurl - taking long time on curl_easy_perform 11 400
valid enum? 6 74
Unable to start eclipse ? 17 141
How to access ANSI/IEEE Std 754 or equivalent information ? 3 63
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question