About 847,000 results
Open links in new tab
  1. Why is there a 10 after I print a char array? - Stack Overflow

    Sep 23, 2014 · 10 is a newline. fgets consumes the newline and copies it to the buffer. From the docs: Parsing stops if end-of-file occurs or a newline character is found, in which case str will contain that newline character. The documentation is your friend.

  2. c++ - On inputting a string of more than 10 characters in a char array

    Dec 23, 2019 · Use std::string instead of a fixed-size C array, or use a "safe" function from stdio.h that lets you specify the size of the buffer. @parktomatomi What does std::string do? And where should I add it? It's the idiomatic way to store a string in C++. You can use it in most places instead of char *.

  3. Why all the characters of an array are not printed?

    Jun 21, 2023 · Using the %s type specifier with printf for an array that is not null terminated is an error. You may get lucky or the contents of the a array will be printed and followed by garbage characters (whatever is in memory until a null is encountered) …

  4. c - Printing an array of characters - Stack Overflow

    You declare an array of characters like so: char foo[size]; You seem to have it mixed up with char *, which is a pointer to a character. You could say. char *bar = foo; which would make bar point to the contents of foo. (Or, actually, to the first character of foo.) To then print the contents of the array, you can do one of the following:

  5. Solved Q8. Define an array of size 10 that accepts ten - Chegg

    Define an array of size 10 that accepts ten characters of your choice via keyboard and display the same alphabets. Show the code and output screen. Also show your ID and name on the output screen 09.

  6. C++ Arrays with Examples - CodesCracker

    declares a character-array with a size of 10, indicating that the array "a" can hold up to 10 characters. How to initialize arrays in C++. In C++, the general form for initializing arrays is as follows:

  7. C++ Program to Print ASCII Value of All Characters in the String

    Here is the source code of C++ Program to Display the ASCII Value of the Character Entered. The program output is shown below. 1. The user is asked to enter a character. 2. The ASCII value of the character which is the integer value is printed. Sanfoundry Global Education & Learning Series – C++ Programs.

  8. Solved In C++, Create an array of 10 characters. Use a loop

    In C++, Create an array of 10 characters. Use a loop to prompt for 10 letters (a-z|A-Z) and store each in the array. If an invalid character is entered, re-prompt until a valid char is entered. After 10 characters are stored in the array, use a loop to print out all characters in the array from the first to the last element.

  9. Write a C or a C++ program that reads 10 characters from the …

    Apr 5, 2022 · Write a C or C++ program that reads 10 characters from the user, and then searches for the position of the character 'z'. How would it be done? char s1[X]; for(int i = 0; i < 10; i++) printf("Char %d = ", i + 1); scanf("%s", s1); printf("Char Z index ="); int index; char y = 'z'; for(int i = 0; i<10; i++) if(s1[i] == y) index=i; // return;

  10. Keyboard input: Array of characters - C++ Programming

    I'm having difficulty stepping through my array. I don't know if I need an iteration inside the switch statement or not. I'd like to step through the array and fill up as many buckets (up to ten) as I want with numbers (0-9). Convert that string to an integer, add one …

  11. Some results have been removed
Refresh