Simple press the keys one by one, end finally press Enter.
But if you meant: how the read from keyboard, then use functions like fgets or scanf. (Use the help/manual of your system for details.)
Console.WriteLine("Please input a string:"); string str = Console.ReadLine(); Console.WriteLine("Number of characters: " + str.Length);
The getchar() is used in 'C' programming language because it can read the character from the Standard input(i.e..from the user keyboard),and converts in to the ASCII value.
// get input char input[256]; gets(input); // print one character on each line int i; for(i = 0; input[i] != '\0'; ++i) { printf("%c\n", input[i]); }
std::string input = ""; std::getline (std::cin, input); // get input from stdin std::stringstream ss (input); // place input in a string stream integer num = 0; if (ss >> num) // extract integer from string stream { // Success! } else { // Fail! }
its simple in c and c++: mainly it depends on what type of answer ur looking track fro the user .. if its a numeric u can define a integer or float variable else a string variable to store characters . ex : printf("\n whats ur age ?"); scanf("%d",&age); printf("\n hey ur %d years old :",age); cout
Console.WriteLine("Please input a string:"); string str = Console.ReadLine(); Console.WriteLine("Number of characters: " + str.Length);
scanf();
The getchar() is used in 'C' programming language because it can read the character from the Standard input(i.e..from the user keyboard),and converts in to the ASCII value.
You press ctrl, shift, c on your keyboard and then input your code.
// get input char input[256]; gets(input); // print one character on each line int i; for(i = 0; input[i] != '\0'; ++i) { printf("%c\n", input[i]); }
std::string input = ""; std::getline (std::cin, input); // get input from stdin std::stringstream ss (input); // place input in a string stream integer num = 0; if (ss >> num) // extract integer from string stream { // Success! } else { // Fail! }
You mean read from file/standard input? With function fgets.
just use fgets() from file stdio.h (not gets: it is security hole)
A synonym for literal: 12, -1.3, "string", 'a'
In simple terms, unformatted input and output is the most primitive form of input and output. It typically offers the most compact storage but is generally less portable than formatted input and output. If we consider the decimal value 1.23, there are various ways we can output this value. We might choose to use unformatted output using IEEE 754 encoding, creating the 4-byte binary value 0x3f9d70a4. However, in order to input this value upon another system, we must first tell that other system to expect an IEEE 754 value otherwise the binary value could be interpreted as being the integer value 1,067,282,596 or the character sequence "? p ¤ " or something else entirely. With formatted input and output, instead of the value 1.23 we output the null-terminated string "1.23", thus creating the 5-byte binary value 0x312e323300. When we come to input that value, the system does not need to know the specifics of the encoding, it simply needs to know that the input is formatted. Thus we read back the string "1.23", which can then be converted to the floating point value 1.23 using whatever encoding the system actually supports. Humans typically input data in formatted form using character sequences. So when entering the value 1.23 from the keyboard, we generate the string "1.23". If the system knows that it is expecting a floating point value, then it will attempt to convert the string accordingly, creating unformatted data from the formatted input. Similarly, when the computer presents the unformatted value 1.23 as output to the user, it is converted back to a string creating formatted output from the unformatted data. When we create formatted output from unformatted output, we can also choose to decorate the output, such that the unformatted value 1.23 might be represented as the formatted value "£1.23" if the value happens to represent a UK currency value. Similarly, we can do a reverse conversion when the user inputs the formatted value "£1.23".
its simple in c and c++: mainly it depends on what type of answer ur looking track fro the user .. if its a numeric u can define a integer or float variable else a string variable to store characters . ex : printf("\n whats ur age ?"); scanf("%d",&age); printf("\n hey ur %d years old :",age); cout
For input: scanf("%d",&the value u wanna get into pgm); For output: printf("%d",the value u wanna give to out); Note: u ve to be sure in the letter u put after %.because it ll change depends on variable.eg:int,char,floatdouble,string,decimal,hex,oct..etc Rgds, BM