Click here to Skip to main content
15,891,769 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: c++ titlebar color change Pin
RenateD31-Jan-10 6:40
RenateD31-Jan-10 6:40 
GeneralRe: c++ titlebar color change Pin
enhzflep31-Jan-10 6:58
enhzflep31-Jan-10 6:58 
GeneralRe: c++ titlebar color change Pin
RenateD31-Jan-10 9:19
RenateD31-Jan-10 9:19 
GeneralRe: c++ titlebar color change Pin
enhzflep31-Jan-10 17:46
enhzflep31-Jan-10 17:46 
QuestionAPI For ClipBoard Pin
Anil Kumar.Arvapalli31-Jan-10 2:09
Anil Kumar.Arvapalli31-Jan-10 2:09 
AnswerRe: API For ClipBoard Pin
Ed.Poore31-Jan-10 2:24
Ed.Poore31-Jan-10 2:24 
AnswerRe: API For ClipBoard Pin
Richard MacCutchan31-Jan-10 2:48
mveRichard MacCutchan31-Jan-10 2:48 
Questionsave file error! Pin
wbgxx31-Jan-10 1:54
wbgxx31-Jan-10 1:54 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define STOP 0
#define TRUE 1
#define OK   1
#define FILE_NAME ("my.text")

typedef struct List
{
	long lNum;
	char cpsName[30];
	long lCScore;
	long lMathScore;
	long atol(long i);
	struct List *next;
}Stu;

Stu stuList[3] = 
{
	{1, "asd", 32, 44, 0},
	{2, "ffg", 66, 66, 0},
	{3, "dgd", 55, 44, 0},
};

Stu *CreateList()
{
	Stu *head = NULL;
	Stu *NewNode = NULL;
	int i = 0;

	for (i=0; i<3; i++)
	{
		NewNode = (Stu*)malloc(sizeof(Stu));

		NewNode->lNum = stuList[i].atol(stuList[i].lNum);
		strncpy(NewNode->cpsName, stuList[i].cpsName, 30);
		NewNode->lCScore = stuList[i].atol(stuList[i].lCScore);
		NewNode->lMathScore = stuList[i].atol(stuList[i].lMathScore);
		NewNode->next = NULL;

		if (NULL == head)
		{
			head = NewNode;
		}
		else
		{
			head->next = NewNode;
			head = NewNode;
		}
	}

	return head;	
	
}

int SaveToFiles(Stu *head)
{
	Stu *p = head;
	FILE *fp;
	char cFileName[1024] = {0};
    //strcpy(cFileName, FILE_NAME);
	
	if ((fp = fopen(FILE_NAME, "wb")) == NULL)
	{
		printf( "Open file error!\n" );
		exit (1);
	}

	while (p != NULL)
	{
		if (fwrite(p, sizeof(Stu), 1, fp) == 1)
		{
			p = p->next;
		}
		else
		{
			printf("Write file error!\n");
			exit(1);
		}
	
	}
	fclose(fp);

	printf( "Save file succeed!\n" );
	return OK;
}

int OpenFiles()
{

	char cFileName[256] = {0};
	FILE *fp;
	if (0 == (fp = fopen(FILE_NAME, "r")))
	{
		printf("Open file error!\n");
		exit(0);
	}
	
    fgets(cFileName, 250, fp);
	printf("%s", cFileName);
	fclose(fp);
	return OK;
}

int main()
{
	Stu *head = NULL;

	head = CreateList();
	SaveToFiles(head);
	OpenFiles();
	//Print(head);

    return 0;
}




this is the error information:
error LNK2001: unresolved external symbol "public: long __thiscall List::atol(long)" (?atol@List@@QAEJJ@Z)
Debug/file.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
AnswerRe: save file error! Pin
Richard MacCutchan31-Jan-10 2:44
mveRichard MacCutchan31-Jan-10 2:44 
GeneralRe: save file error! Pin
wbgxx31-Jan-10 3:41
wbgxx31-Jan-10 3:41 
GeneralRe: save file error! Pin
Richard MacCutchan31-Jan-10 4:05
mveRichard MacCutchan31-Jan-10 4:05 
GeneralRe: save file error! Pin
wbgxx31-Jan-10 4:28
wbgxx31-Jan-10 4:28 
GeneralRe: save file error! Pin
enhzflep31-Jan-10 4:14
enhzflep31-Jan-10 4:14 
GeneralRe: save file error! Pin
Richard MacCutchan31-Jan-10 6:19
mveRichard MacCutchan31-Jan-10 6:19 
GeneralRe: save file error! Pin
enhzflep31-Jan-10 6:40
enhzflep31-Jan-10 6:40 
GeneralRe: save file error! Pin
Richard MacCutchan31-Jan-10 7:44
mveRichard MacCutchan31-Jan-10 7:44 
Questionuser defined drag drop control in vc++ Pin
Prajakta Apte 31-Jan-10 1:44
Prajakta Apte 31-Jan-10 1:44 
Questionsave file error! Pin
wbgxx31-Jan-10 1:25
wbgxx31-Jan-10 1:25 
AnswerRe: save file error! Pin
Cedric Moonen31-Jan-10 1:43
Cedric Moonen31-Jan-10 1:43 
AnswerRe: save file error! Pin
Richard MacCutchan31-Jan-10 2:38
mveRichard MacCutchan31-Jan-10 2:38 
QuestionProblem with CFile:Open and Sharing Violation [modified] Pin
hollesser00130-Jan-10 23:20
hollesser00130-Jan-10 23:20 
AnswerRe: Problem with CFile:Open and Sharing Violation Pin
Garth J Lancaster31-Jan-10 0:09
professionalGarth J Lancaster31-Jan-10 0:09 
QuestionRe: Problem with CFile:Open and Sharing Violation Pin
hollesser00131-Jan-10 3:00
hollesser00131-Jan-10 3:00 
Questiondetect enter key on edit control Pin
Sauce!30-Jan-10 22:14
Sauce!30-Jan-10 22:14 
AnswerRe: detect enter key on edit control Pin
Alain Rist30-Jan-10 23:02
Alain Rist30-Jan-10 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.