6
66650755
Now,I have this pointer of array:
char *Ptr[SIZE]={"HeArd","DiaMoNd","SprAde","AbC"};
I'd like to conver all the upper-case letters to lower-case ones.So I
writted the follwing program:
#include<stdio.h>
#include<ctype.h>
#define SIZE 4
void convertolower(char *Ptr[],int size);
int main()
{
char *Ptr[SIZE]={"HeArd","DiaMoNd","SprAde","AbC"};
int i;
convertolower(Ptr,SIZE);
for(i=0;i<=3;i++)
{
printf("%s\n",Ptr);
}
return 0;
}
void convertolower(char *Ptr[],int size)
{
int i;
int k;
for(i=0;i<=3;i++)
{
for(k=0;*(Ptr)!='\0';Ptr++,k++)
{
if( isupper( *Ptr ) )
{
*Ptr = tolower( *Ptr );
}
}
Ptr-=k;//let Ptr point back to the start of it's corresponding
string
}
}
When I debug it,and come to this centence:
*Ptr = tolower( *Ptr );
the compiler said:access violation.
How come? And is there any other means to conver the upper-case letter
to lower ones?
char *Ptr[SIZE]={"HeArd","DiaMoNd","SprAde","AbC"};
I'd like to conver all the upper-case letters to lower-case ones.So I
writted the follwing program:
#include<stdio.h>
#include<ctype.h>
#define SIZE 4
void convertolower(char *Ptr[],int size);
int main()
{
char *Ptr[SIZE]={"HeArd","DiaMoNd","SprAde","AbC"};
int i;
convertolower(Ptr,SIZE);
for(i=0;i<=3;i++)
{
printf("%s\n",Ptr);
}
return 0;
}
void convertolower(char *Ptr[],int size)
{
int i;
int k;
for(i=0;i<=3;i++)
{
for(k=0;*(Ptr)!='\0';Ptr++,k++)
{
if( isupper( *Ptr ) )
{
*Ptr = tolower( *Ptr );
}
}
Ptr-=k;//let Ptr point back to the start of it's corresponding
string
}
}
When I debug it,and come to this centence:
*Ptr = tolower( *Ptr );
the compiler said:access violation.
How come? And is there any other means to conver the upper-case letter
to lower ones?