Home > Software engineering >  MFC to write read. Hea error will not change the file code. Turn to the great god!
MFC to write read. Hea error will not change the file code. Turn to the great god!

Time:10-06

The file name 100. Hea

The file content:
100 2 360 650000
11, 1024, 995-22131 212 200 100. Dat 0 MLII
11 1024 1011 20052 212 200 100. Dat 0 V5
# 69 M 1085 1629 x1
# Aldomet, Inderal

In addition to the system generated code I added code below
BOOL CECG2Doc: : OnOpenDocument (LPCTSTR lpszPathName)
{
if (! CDocument: : OnOpenDocument (lpszPathName))
return FALSE;

//TODO: here to add your special creation code
CFile hfile;
Cstrings info [25];
Cstrings tempinfo;
Int m=0;
Hfile. Open (_T (" C: \ Users \ Desktop \ 100. Hea "), CFile: : modeRead);
Char pbufs [500].
Hfile. Read (pbufs, sizeof (pbufs));
Char * HP;
HP=& amp; Pbufs [0].
For (int k=0; K<=sizeof (pbufs); K++)
{
If (m==25)
{
break;
}
If ((int) * HP==10 | | (int) * HP==13)
{
Hp++;
}
If (* HP!=' '& amp; & (int) * HP!=10 & amp; & (int) * HP!=13)
{
Tempinfo=tempinfo + (cstrings) (* HP);
}
The else
{
The info [m]=tempinfo;//remove the read information stored in the array
Tempinfo="";
M++;
}
Hp++;
}

M_case. M_ID=info [0];//the medical record information stored in the structure
M_case. M_dao0=info [12].
M_case. M_dao1=info [21].
M_case. M_Name=info [13].
If (info [24]=="F")
{
M_case. M_Sex="female";
}
The else
{
M_case. M_Sex="male";
}
M_case. M_Age=info [23].
Hfile. Close ();
return TRUE;
}

H
the statement in stafx.Struct {//statement structure m_case
Cstrings m_ID;
Cstrings m_dao0;
Cstrings m_dao1;
Cstrings m_Name;
Cstrings m_Sex;
Cstrings m_Age;
} m_case;
Program error is as follows:
The first wrong out in hfile. Open (_T (" C: \ Users \ Desktop \ 100. Hea "), CFile: : modeRead);
1> C: \ users \ documents \ visual studio 2010 \ projects \ ecg2 \ ecg2 \ ecg2doc CPP (150) : warning C4129: ": do not identify escape sequences of characters
1> C: \ users \ documents \ visual studio 2010 \ projects \ ecg2 \ ecg2 \ ecg2doc CPP (150) : warning C4129: a "D" : do not identify escape sequences of characters
The second fault lies in a
1> Stdafx. Obj: error LNK2005: "struct & lt; Unnamed - type - m_case & gt; (m_case "? M_case @ @ 3 u & lt; Unnamed - type - m_case & gt; @ @ A) has been ECG2Doc. Obj defined in
1> C: \ Users \ Documents \ Visual Studio 2010 \ Projects \ ECG2 \ Debug \ ECG2 exe: fatal error LNK1169: locate one or more of the definition of multiple symbol

CodePudding user response:

Hfile. Open (_T (" C: \ Users \ Desktop \ 100. Hea "), CFile: : modeRead);

CodePudding user response:

Hfile. Open (_T (" C: \ Users \ Desktop \ 100. Hea "), CFile: : modeRead); In this line of code has a problem, the double quotes \ should be changed to \ \ the
Hfile. Open (_T (" C: \ \ Users \ \ Desktop \ \ 100. Hea "), CFile: : modeRead);

CodePudding user response:

Escape \ \ \ said just said the backslash
The header file to add
#pragma once

CodePudding user response:

reference zgl7903 reply: 3/f
escape \ \ \ said just said the backslash
The header file to add
# pragma once

Header file has a # pragma once, or an error multiple definition

CodePudding user response:

Using extern declaration in the header file
Entity written in the book. C or.
in the CPP

CodePudding user response:

reference 5 floor zgl7903 reply:
using extern declaration in the header file
Entity written in the book. C or. CPP in

A great god, and I think in the view window display member variable values, such as in my code above m_Age values, how to do? Is written in the ontouch? Can't write variables TextOut is write constants? Please explain a little bit in detail

CodePudding user response:

.h
Typedef struct _tagMCaset_t
{
Cstrings m_ID;
Cstrings m_dao0;
Cstrings m_dao1;
Cstrings m_Name;
Cstrings m_Sex;
Cstrings m_Age;
} MCASE, * LPMCASE;
Extern MCASE m_Case;

.cpp
MCASE m_Case;

CodePudding user response:

refer to 7th floor zgl7903 response:
h
Typedef struct _tagMCaset_t
{
Cstrings m_ID;
Cstrings m_dao0;
Cstrings m_dao1;
Cstrings m_Name;
Cstrings m_Sex;
Cstrings m_Age;
} MCASE, * LPMCASE;
Extern MCASE m_Case;

.cpp
MCASE m_Case;

The great god, this understand, I asked another question, you can have a look at the trouble

CodePudding user response:

Int m_Age;


Cstrings strAge.
StrAge. The Format (' Age=% d ", m_Age);
PDC - & gt; TextOut (0, 0, strAge);

CodePudding user response:

references 9 f schlafenhamster response:
int m_Age;


Cstrings strAge.
StrAge. The Format (' Age=% d ", m_Age);
PDC - & gt; TextOut (0, 0, strAge);

I define m_Age is cstrings, this isn't just pDC - & gt; TextOut (0, 0, m_Age)? But I only write the program error said m_Age statement, but I have been in the stdafx. H wrote
Typedef struct _tagMCaset_t
{
Cstrings m_ID;
Cstrings m_dao0;
Cstrings m_dao1;
Cstrings m_Name;
Cstrings m_Sex;
Cstrings m_Age;
} MCASE, * LPMCASE;
Extern MCASE m_Case;

In the Doc. CPP and View. The CPP in wrote
MCASE m_Case;

CodePudding user response:

PDC - & gt; TextOut (0, 0, m_Case. M_Age);//must be m_Case object
  • Related