Considering the following lines of C code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void print_upper(char *string);
int main()
{
char s[80];
printf("enter a string\n");
gets(s);
print_upper(s);
printf("\ns is now in upper case: %s",s);
return 0;
}
void print_upper(char *string)
{
register int t;
int k;
for(t=0;string[t];++t)
{
string[t]=toupper(string[t]);
putchar(string[t]);
}
}
In the function,print_upper(char *string)
there is a for loop which looks like:
for(t=0;string[t];++t)
{
string[t]=toupper(string[t]);
putchar(string[t]);
}
}
Now,how exactly does this for loop work?
I knew the structure of for loop to be like
for(i=0;i<10;i+=1)
{
\\code;
}
So I am kind of confused about it.
Thanks in advance.