| |

VerySource

 Forgot password?
 Register
Search
View: 699|Reply: 7

How to resolve this simple error?

[Copy link]

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-18 12:30:01
| Show all posts |Read mode
#define INIFILE "ckini.ini"

FILE * fp = NULL;
char SystemPath [MAX_PATH] = {0};
GetSystemDirectory (SystemPath, MAX_PATH);

int len ​​= strlen (SystemPath) -1;
if (SystemPath [len]! = '\\')
strcat (SystemPath, "\\");
strcat (SystemPath, INIFILE);

fp = fopen (SystemPath, "r");
if (fp == NULL)
{
return FALSE;
}

fread (&Ini [0], sizeof (Ini), 1, fp);
fclose (fp);

m_Edit1.SetWindowText (fp);

error C2664: 'SetWindowTextA': cannot convert parameter 1 from 'struct _iobuf *' to 'const char *'
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-23 02:45:02
| Show all posts
Halo ~~
m_Edit1.SetWindowText (fp); // fp is the file pointer

To:

m_Edit1.SetWindowText (SystemPath);
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-28 11:00:02
| Show all posts
Who can annotate

What is this consciousness
fread (&Ini [0], sizeof (Ini), 1, fp);
fclose (fp);
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-28 15:00:01
| Show all posts
fread (&Ini [0], sizeof (Ini), 1, fp); // Read the file and store it in the Ini array, the size is sizeof (Ini)
fclose (fp); // Close the file
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-5-1 15:15:01
| Show all posts
Can the brother upstairs put the read file in the EDIT control?
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-6-5 16:30:02
| Show all posts
FILE *file = fopen("c:\\work\\test.txt","r"); //c:\\work\\test.txt is the name of the file to be read.
char read_Txt[40] = {0};
int number =0;
number = fread(read_Txt, sizeof(char), sizeof(read_Txt), file);
fclose(file);
m_Value = read_Txt;
UpdateData(FALSE); //Pass the value of m_Value to the Edit control. m_Value is a variable bound to the control.
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-6-27 15:30:01
| Show all posts
IniInfor Ini[2] = {0};
BOOL CReadIniDlg::ReadIniFile()
{
UpdateData();

FILE* fp = NULL;
char SystemPath[MAX_PATH] = {0};
GetSystemDirectory( SystemPath, MAX_PATH );

int len ​​= strlen(SystemPath)-1;
if (SystemPath[len] != '\\')
strcat(SystemPath,"\\");
strcat(SystemPath,INIFILE);

fp = fopen (SystemPath, "r" );
if (fp == NULL)
{
return FALSE;
}

fread(&Ini[0], sizeof(Ini), 1, fp);//Read the file and store it in the Ini array, the size is sizeof(Ini)
fclose(fp);//Close the file

m_Edit2.SetWindowText((char*)&Ini[1]);
m_Edit2.SetWindowText((char*)&fp); //Why is the garbled text read here?

UpdateData(false);
return TRUE;
}
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-7-24 13:30:02
| Show all posts
Why there are only 2 elements IniInforIni[2] = {0};
m_Edit2.SetWindowText((char*)&fp); What is this sentence?
fread(array, element length, number of elements read, fp), you used the wrong method.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list