Home > Back-end >  Visual stdio gets function
Visual stdio gets function

Time:10-23

Gets in visual how to run it inside the

CodePudding user response:

Use get_s

CodePudding user response:

Is change gets to get_s?

CodePudding user response:

Is change gets to get_s?

CodePudding user response:

Gets (buffer)//function to limit the length of the input is not
//so there will be warnings in vs with gets This function or variable may be unsafe.

Gets_s (buffer size)//which is allowed to enter the second parameter length
//here is the size of the length of the allocated buffer 1 just right, otherwise for '\ 0' automatically allocate space will overflow,

See the code below:


#include
Int main (void)
{
Char buffer [21].//20 chars + '\ 0'
Gets_s (buffer, 20);//written after the 21st, when entering 21 characters enter, automatically add '\ 0', will require allocation of storage space
Printf (" Your input was % s \ n ", buffer);
system("pause");
return 0;
}

CodePudding user response:

Fun
reference 4 floor response:
gets (buffer)//function to limit the length of the input is not
//so there will be warnings in vs with gets This function or variable may be unsafe.

Gets_s (buffer size)//which is allowed to enter the second parameter length
//here is the size of the length of the allocated buffer 1 just right, otherwise for '\ 0' automatically allocate space will overflow,

See the code below:


#include
Int main (void)
{
Char buffer [21].//20 chars + '\ 0'
Gets_s (buffer, 20);//written after the 21st, when entering 21 characters enter, automatically add '\ 0', will require allocation of storage space
Printf (" Your input was % s \ n ", buffer);
system("pause");
return 0;
}

This is not the length of the problem, the visual stdio display gets and get_s are said to find identifier, I know \ 0 to account for a memory characters

CodePudding user response:

Vs does not support the gets function, get_s the function, is get (the function name, length), the mean?

CodePudding user response:

Sorry, wrong number then ~ ~

Is gets_s (), vs prefer a more secure

CodePudding user response:

refer to 7th floor and 蘤 old crepe reply:
sorry, wrong number then ~ ~

Is gets_s (), vs like to use a more secure

But I knock on get_s (STR, 225) is an error

CodePudding user response:

refer to the eighth floor weixin_46360087 response:
Quote: refer to 7th floor and 蘤 old crepe reply:
sorry, wrong number then ~ ~

Is gets_s (), vs like to use a more secure

But I knock on get_s (STR, 225) is also an error

I've learned that knock gets_s less an s, and the scanf (% s) is also similar, thank you,

CodePudding user response:

Under the vs gets replaced by gets_s, replace it.

Anything else gets_s, post

CodePudding user response:

make fun of the reference to the tenth floor response:
vs gets be gets_s replaced, replace it.

Gets_s still have what problem, post

B: no, thank you, will continue to work hard

CodePudding user response:

11 references and 蘤 old crepe reply:
gets_s (STR + 1225) a try, my side not vs, try not

Get the results of this program is the same

CodePudding user response:

reference 13 floor weixin_46360087 reply:
Quote: 11 references and 蘤 old crepe reply:
gets_s (STR + 1225) a try, my side not vs, try not

Get the results of this program is the same as


To see a sample code is that the thought pass the address of the need to push back, your problem just dialed the wrong number, see, no problem, write only one storage location after

CodePudding user response:

on the 14th floor and reference 蘤 old crepe response:
Quote: refer to the 13th floor weixin_46360087 response:

Quote: refer to the 11 floor and 蘤 old crepe reply:
gets_s (STR + 1225) a try, my side not vs, try not

Get the results of this program is the same as


To see a sample code is that the thought pass the address of the need to push back, your problem just dialed the wrong number, see, no problem, so write only one storage location after

Uh huh, understand, and finally have \ 0 to account for a character

CodePudding user response:

reference 15 floor weixin_46360087 response:
Quote: on the 14th floor and reference 蘤 old crepe response:
Quote: refer to the 13th floor weixin_46360087 response:

Quote: refer to the 11 floor and 蘤 old crepe reply:
gets_s (STR + 1225) a try, my side not vs, try not

Get the results of this program is the same as


To see a sample code is that the thought pass the address of the need to push back, your problem just dialed the wrong number, see, no problem, so write only one storage location after

Uh huh, understand, and finally have \ 0 to account for a character


No, he is in his head to set aside a place, can not leave

CodePudding user response:

reference 16 floors and 蘤 old crepe reply:
Quote: reference 15 floor weixin_46360087 response:

Quote: on the 14th floor and reference 蘤 old crepe response:
Quote: refer to the 13th floor weixin_46360087 response:

Quote: refer to the 11 floor and 蘤 old crepe reply:
gets_s (STR + 1225) a try, my side not vs, try not

Get the results of this program is the same as


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related