Hi I have 2 questions:
First question:
Code:
void cp_even()
{ int j;
j=0;
int i,a[6],b[j],*ptra, *ptrb;
printf("Enter SIX values:");
for(i=0; i<=5; i++)
{
scanf("%d",&a[i]);
if(a[i]%2==0)
{
b[j]=a[i];
j++;
}
}
ptra=&a[0];
ptrb=&b[0];
............................... end of the code
}
My problem with the bold font in the code, I recieve this missage:
: error C2057: expected constant expression
I don't know why it says that; j=0 is constant! (this works in java)
Second question:
Code:
void upperCase(char *ptr)
{
//ptr=&string[0];
while(*ptr!='\0')
{
if(islower(*ptr))
*ptr=toupper(*ptr);
ptr++;
}
}
void p8()
{
char string[3];
printf("Tybe a string in lower case");
gets(string);
upperCase(string);//change to *ptr
printf("The string in uppercase: %s",string);
}
The code works fine, BUT after displaying the out put on the screen I recieve this message:
Debug error!
......... some paths
Run-Time check Failure #2 - stack around the variable 'string' was corrupted.....
Thankx