1752716 Members
5320 Online
108789 Solutions
New Discussion юеВ

Re: Pro*C Error

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor
Solution

Re: Pro*C Error

>fscanf(infile, "%s", &uidx);

What is the type of uidx? A %s should match a char* or a char array.

>exit;

If you want to exit, you need: exit(0);
NDhivya
Advisor

Re: Pro*C Error

udix is a char array.

Dennis Handly
Acclaimed Contributor

Re: Pro*C Error

>udix is a char array.

That isn't valid. Using &udix is a char**. This doesn't match %s. So remove the &.
NDhivya
Advisor

Re: Pro*C Error

It worked :D
But i dont understand why & should be removed.
Can you please explain?
NDhivya
Advisor

Re: Pro*C Error

Dennis,

I get an error,

"sc_upload_loads2.c", line 381: warning #2181-D: argument is incompatible with
corresponding format string conversion
roll_size, prod_order_tons);
^

in a statement " printf ("%6d %2d %6.2f %4.2f\n", weyer_order_no, count_knives,
roll_size, prod_order_tons);"


prod_order_tons is of type int.

I get another error,

"sc_upload_loads2.c", line 1301: warning #2181-D: argument is incompatible
with corresponding format string conversion
scanf ("%f", price);
^
here price is of type float.

Please suggest.

Thanks,
Dhivya
Dennis Handly
Acclaimed Contributor

Re: Pro*C Error

>But i don't understand why & should be removed. Can you please explain?

I already did. %s wants a char*. A char[] gets converted to a char*. But what you have gives:
warning #2144-D: a value of type "char (*)[20]" cannot be used to initialize an entity of type "char *"
char *p = &buf;

>warning #2181-D: argument is incompatible with corresponding format string conversion
>printf("%6d %2d %6.2f %4.2f\n", weyer_order_no, count_knives, roll_size, prod_order_tons);"

If you are happy with the answers please read the following on how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
>prod_order_tons is of type int.

An int doesn't match %4.2f, only a double matches.

>warning #2181-D: argument is incompatible
with corresponding format string conversion
>scanf("%f", price);
>here price is of type float.

scanf(3) wants pointers:
scanf("%f", &price);
NDhivya
Advisor

Re: Pro*C Error

Hi Dennis,

Thanks a lot.

Now, we get the below error,

/usr/ccs/bin/cc -c +DD64 -I. -I../lib -I/u01/dba/oracle/product/1012ias/precomp/public down_cards.c
"down_cards.c", line 315: warning #4212-D: mismatch between character pointer
types "unsigned char *" and "char *"
varcopy(uid,uidx);
^

Here,
#define varcopy(x,y) x.len=strlen(strcpy(x.arr,y))

Declarations:
char uidx[20];
struct { unsigned short len; unsigned char arr[20]; } uid;

Please suggest.
Dennis Handly
Acclaimed Contributor

Re: Pro*C Error

>warning #4212-D: mismatch between character pointer types "unsigned char*" and "char*"

You can either ignore it, suppress it (+W4212) or use a hammer:
#define varcopy(x,y) x.len=strlen(strcpy((char*)(x.arr),y))

I'm not sure you want to change the type of "arr".
NDhivya
Advisor

Re: Pro*C Error

Thanks a lot for your valuable suggestions Dennis. I helped us a lot.

Regards,
Dhivya
NDhivya
Advisor

Re: Pro*C Error

With the help of Dennis we could solve the issues.