I found a string to upper function that looks like this:
char *strupr(char *string)
{
char *s;
if (string)
{
for (s = string; *s; ++s)
*s = toupper(*s);
}
return string;
}
It works and all is ok, but I thought I could trim it down to the
following that doesn't work:
char *strupr(char *string)
{
// char *s;
if (string)
{
// for (s = string; *s; ++s)
for (string; *string; ++string)
// *s = toupper(*s);
*string = toupper(*string );
}
return string;
}
Can someone explain why the bottom function doesn't work? Thanks!
char *strupr(char *string)
{
char *s;
if (string)
{
for (s = string; *s; ++s)
*s = toupper(*s);
}
return string;
}
It works and all is ok, but I thought I could trim it down to the
following that doesn't work:
char *strupr(char *string)
{
// char *s;
if (string)
{
// for (s = string; *s; ++s)
for (string; *string; ++string)
// *s = toupper(*s);
*string = toupper(*string );
}
return string;
}
Can someone explain why the bottom function doesn't work? Thanks!
Comment