this is always the case when it comes to self-learning what is wrong with the structure.
this is always the case when it comes to self-learning what is wrong with the structure.
first of all, put your code into a code, and use this site's own editor / markdown format to format it, cut it, and never replace it.
as for your code, there are two questions:
scanf_s
is a private account of msvc
. It requires you to give length information, but you don't. scanf_s/scanf
accepts const char *
, and here your name
is of type char [4]
, that is, it is a group of characters, do not equate the number of characters with fingers, it is of different types ( derived type
). However, the number group can sometimes be converted into a reference, for example, in scanf_s/scanf
here, the required form (parameter) refers to the number, right, but the actual (argument) you give is the number, and a transformation occurs when the parameter is transmitted, and the parameter group is read to the reference. If you pass in & name
, then you need to understand that the values of name
and & name
are certainly the same (both are binary numbers, which can be understood as addresses), but the type of category is different. The type of name
is listed above, which is char [4]
, and which can be converted to reference. However, the type of & name
is actually char (*) [4]
. It is an indicator pointing to the number group (whose length is 4) and cannot be transferred to const char *
. Which is the type required by scanf/scanf_s
. So it triggers a routine. solution:
scanf_s("%s", stu.name, sizeof(stu.name));
traditional version:
first of all, change your code picture into code, and format it into code format with our own editor / markdown syntax. Remember, never post code pictures.
as for your code, there are two problems:
scanf_s
is a contraband of msvc
. It requires you to give length information, but you don't. scanf_s/scanf
accepts const char *
, and here your name
is of type char [4]
, that is, it is a character array, do not equate the character array with the pointer, they are two different types ( derived type
). However, arrays can sometimes be implicitly converted to pointers, for example, in scanf_s/scanf
, the required parameter (parameter) is a pointer, right, but the argument (argument) you give is an array, and an implicit conversion occurs when the parameter is passed, from the array brick to the pointer. If you pass in & name
, then you need to understand that although the values of name
and & name
are the same (both are binary numbers and can be understood as addresses), their types are different. As mentioned above, the type of name
is char [4]
, and which can be implicitly converted into pointers. However, the type of & name
is actually char (*) [4]
, which is a pointer to an array (whose length is 4). Cannot be implicitly converted to const char *
, which is the type required by scanf/scanf_s
. So an exception was thrown. solution:
scanf_s("%s", stu.name, sizeof(stu.name));
Previous: Prefix=null
Next: How nginx replaces external picture links that are referenced in a website that do not exist
recently, we are going to do a leave function. Student A submitted an application for leave, which was then reviewed by teacher B, but later I found that I needed a reminder function on Wechat s message end. It seems that Wechat can only use template me...
1. Write the landing page with react, after calling the background data with axios, judge the route of the page to jump according to the return value, how to jump? 2.axios.get ( login login.action?username= +name+ &password= +pd, {) timeout: 1000...
The horizontal coordinates of echarts are not specifically marked, and the X coordinates do not have a grid to indicate. Here is a figure that specifies . js * * createChartSix() { this.$http .get(this.$api.dataChart) .then(rsp => { ...
sincerely ask for advice: < hr > I want to use node as the background to build a video streaming server. The front end is similar to Youku VOD. It can record the playback node function, and load the progress bar at any point (starting from the c...
I can succeed with this https: www.jianshu.com p 293., but it is a font-class reference and is displayed in monochrome. I d like a color one. dvahtmljs ...
various methods have been tried, including the simplest way to disable the thouchmove event directly. Has the Wechat browser under ios been unable to stop the rebound? ...
setting in state: this.state = {checkList: []}; checkList initializes it with an array of the same length as JsonPage: this.setState ({checkList:checkSaveCount}); checkSavaCount is the same length as the following JsonPage. the following creates...
in order to facilitate development, we plan to create a LNMP environment based on docker, which makes it much more convenient to change computers or unify the team s development environment. choreographed a docker-compose.yaml file with nginx, php-fp...
external network access domain name: https: api.baidu.com internal network domain name: http: local.baidu.com this domain name is inaccessible outside the network! It is 127.0.0.1 pointed to by a private network address. I use nginx reverse proxy ...
I need to implement in a chained promise function, any function error in the middle terminates the program, and can catch the error function, and then perform different operations according to different error functions. How can the following code be imp...
import React from react ; class PublicScreen extends React.Component { constructor(props) { super(props); this.getStyle = this.getStyle.bind(this); } getStyle() { const { width = 1920, height = 1080 } = this.pr...
I would like to ask what is wrong with this code. Thank you for your answers. ...
renderdphtmldvareturnapiBackend: apiBackend ...
is doing a question on Niuke.com. I encounter a problem: to achieve the function callIt, after the call meets the following conditions 1, the returned result is the result after calling fn 2, and the call parameter of fn is all the parameters after th...
https: blog.csdn.net baidu_3. I can configure domain according to his settings, but I want him to change it into a subdomain name such as xxx.ccc.com . How can I set it? do you want to transfer the domain name to the same IP? ServerName...
A timing examination system is triggered if the click event is triggered within 5 seconds, and if it is not triggered, the system marks the correct answer at the end of the countdown. How to implement ...
description: a regular match is given to the content of an input box, and the matching content is the product activation code. looks like this: "0C31-0B81-BB32-3094-0C31-0B81-BB32-3094 " Code: $( -sharplicenseCode ).keyup(function () { le...
1. The custom event triggers the click event of .cpcstartrefresh, but triggers 2 click events each time 2. The code is as follows: window.onmessage = function (e) { create an event object, var myEvent = document.createEvent( Event ); m...
I configured the MIME type of the file with the amr suffix in the apache configuration as application ms-download, Why it is a garbled page when opening a file in amr format using window.open in chrome, while a file in amr format can be successfully dow...
I got a set of data, which is to choose the type of question. How can I tell if I have chosen the right one answera: "Olympic Games " answerb: "Asian Games " answerc: "Paralympic Games " answerd: "University Games " id: "1772 " question: "f...