Computer Methods C Programming
Computer Methods C Programming
LECTURE 8
Strings
return 0;
}
return 0;
}
6 / 20 Computer Methods 1 Lecture 8: Strings
Reading-in strings(cont’d)
/***********************************************
* cm11_8_3.c - This program gets a string from*
* the keyboard and prints it on the screen *
* using scanf *
************************************************/
#include <stdio.h>
#define MAX_LENGTH 10
int main(void) {
return 0;
}
/************************************************************
* function that reads a sequence of characters and stores *
* it in a given array *
************************************************************/
#define ArraySize 80
void reverse(char str[]);
void getLine(char Str[], int Strlen );
int main() {
char Str[ArraySize];
printf("\nEnter the string to be reversed ");
getLine(Str, ArraySize);
/***********************************
* cm11_8_7.c -- Replacement of *
* Upper Case by Lower Case *
**********************************/
#include <stdio.h>
The following is the result of an exe-
void UpperToLower(char str[]);
cution of the program:
int main(void) {
int i; Enter the string
char Str[81]; KwaZulu-Natal
printf("Enter the string\n"); Input = KwaZulu-Natal
scanf("%80s",Str);
printf("\nInput = %s\n", Str); Output = kwazulu-natal
UpperToLower(Str);
printf("\nOutput = %s\n", Str);
return 0;
}