25 lines
462 B
C
25 lines
462 B
C
// Uppercases string using ctype library (and an unnecessary condition)
|
|
|
|
#include <cs50.h>
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(void)
|
|
{
|
|
string s = get_string("Before: ");
|
|
printf("After: ");
|
|
for (int i = 0, n = strlen(s); i < n; i++)
|
|
{
|
|
if (islower(s[i]))
|
|
{
|
|
printf("%c", toupper(s[i]));
|
|
}
|
|
else
|
|
{
|
|
printf("%c", s[i]);
|
|
}
|
|
}
|
|
printf("\n");
|
|
}
|