
Problem
Solution
Submissions
Read and Display the Contents of Input
Certification: Basic Level
Accuracy: 85.71%
Submissions: 14
Points: 10
Write a C++ program that reads and displays the contents from user input. The program should take input from the user and display the contents.
Example 1
- Input: string = "Hello World"
- Output: "Hello World"
- Explanation:
- Step 1: Allocate memory for storing the input string.
- Step 2: Read characters from the standard input stream using pointers.
- Step 3: Store the characters in the allocated memory.
- Step 4: Display the stored string to the standard output stream.
Example 2
- Input: string = "C++ Programming"
- Output: "C++ Programming"
- Explanation:
- Step 1: Allocate memory for storing the input string.
- Step 2: Read characters from the standard input stream using pointers.
- Step 3: Store the characters in the allocated memory.
- Step 4: Display the stored string to the standard output stream.
Constraints
- Input size ≤ 10^6 characters
- Input contains printable ASCII characters
- Time Complexity: O(n) where n is the number of characters in the input
- Space Complexity: O(n) for storing the input
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use string stream to handle input instead of file handling.
- Read the input character by character or line by line.
- Display the contents of the input.