Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 14:
- *
- * Write a program that reads in a line of input and then prints the line in
- * reverse order. You can store the input in an array of char; assume that the
- * line is no longer than 255 characters. Recall that you can use scanf() with
- * the %c specifier to read a character at a time from input and that the
- * newline character (\n) is generated when you press the Enter key.
- */
- #include <stdio.h>
- #include <string.h>
- #define SIZE 256 //we need one more for \n
- int main(void){
- char arr[SIZE];
- printf("Provide a line of character(<= 255): \n");
- int i;
- int notLineEnd = scanf("%c", &arr[0]);
- while(notLineEnd){
- i++;
- notLineEnd = scanf("%c", &arr[i]);
- printf("%d", notLineEnd);
- }
- int j;
- for(j = 0; i < strlen(arr); j++){
- printf("%c", arr[j]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement