Hi all.
I don't need help on writing this as much as I have a question.
Code:
#include <stdio.h>
#include <string.h>
#define MaxStringLength 150
int main( int argc, char** agrv)
{
char userString[ MaxStringLength + 1 ];
char c;
int i;
printf(" Enter a string: ");
fgets(userString, sizeof(userString), stdin);
printf(" capitalized: ");
for (i = 0; i < strlen(userString); i++)
{
c = userString[i];
printf( "%c", UpperString(c));
}
printf( "\n");
return ( 0 );
}
UpperString( char *c)
{
c = toupper(c);
}
My question is should this:
Code:
for (i = 0; i < strlen(userString); i++)
be this:
Code:
for (i = 0; i <= strlen(userString); i++)
It works both ways for me but after being around here for a few weeks I am beginning to think more about efficiency and 'whatif' situations that could break the code.
Just wondering.
Thanks