Home > Back-end >  0 x0f8ad3ec (ucrtbased. DLL) (in the Not. Exe) caused by abnormal: 0 xc0000005: when writing positio
0 x0f8ad3ec (ucrtbased. DLL) (in the Not. Exe) caused by abnormal: 0 xc0000005: when writing positio

Time:11-29

#include

Int main ()
{
Char cha [30];
Scanf_s (" % s ", cha);

Printf (" % s ", cha);

system("pause");
return 0;
}

//0 x0f8ad3ec (ucrtbased. DLL) (in the Not. Exe) caused by abnormal: 0 xc0000005: access violation occurred while writing position 0 x00900000
//I don't think that code if you have any question, why the access conflicts?

CodePudding user response:

The building Lord, should is the usage below:

 # include 
Int main ()
{
Char cha [30]={0};
29 scanf_s (" % s ", cha, _countof (unsigned) (cha));

Printf (" -- \ n % s ", cha);
system("pause");
return 0;
}


You the above mistakes, should be to access memory cross-border,,,

CodePudding user response:

First scanf_s is VS is special, your compiler is VS?

CodePudding user response:

Yes, VS2017

CodePudding user response:

 # include 

Int main ()
{
Char cha [30];
Scanf_s (" % s ", cha, 20).

Printf (" % s ", cha);

system("pause");
return 0;
}
see scanf_s use

CodePudding user response:

The comma write wrong
 # include 

Int main ()
{
Char cha [30];
Scanf_s (" % s ", cha, 20).

Printf (" % s ", cha);

system("pause");
return 0;
}

CodePudding user response:

I know, VS scanf_s usage is different, need to have the length when the input string parameter

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

Made a similar mistake let me dig a fen,,,
Scanf_s (" % s ", cha);
Here is less & amp; The address-of symbols!!!!! Plus!

CodePudding user response:

 scanf_s (" % s ", cha, 30); 

For % s, the original poster is the lack of a parameter, the length of an array of characters
  • Related