Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > error problems

Reply
Thread Tools

error problems

 
 
Bill Cunningham
Guest
Posts: n/a
 
      02-17-2011
I just about have the code I wanted to write written. It compiles but I
have these error codes. This has yet to be converted into an object file and
compiled with some code. What do these errors mean? The compiler wants a
cast and I don't know if I need to convert types use a cast to a similar
type or what. I've tried both these things. Any ideas?

#include <stdio.h>

#define type unsigned int

struct stk {
type date[6];
type price;
type volume;
};

struct stk s, *ps;
struct stk packs(type date[6], type price, type volume)
{
s.date[6] = date[6];
s.price = price;
s.volume = volume;
return s;
}

type unpacks(struct stk * date[6], struct stk * price, struct stk * volume)
{
type date[6];
type price;
type volume;
return date[6] = ps->date;
return price = ps->price;
return volume = ps->volume;

}

mo.c: In function `unpacks':
mo.c:22: warning: declaration of `date' shadows a parameter
mo.c:23: warning: declaration of `price' shadows a parameter
mo.c:24: warning: declaration of `volume' shadows a parameter
mo.c:25: warning: assignment makes integer from pointer without a cast



 
Reply With Quote
 
 
 
 
Fred
Guest
Posts: n/a
 
      02-17-2011
On Feb 17, 10:16*am, "Bill Cunningham" <(E-Mail Removed)> wrote:
> * * I just about have the code I wanted to write written. It compiles but I
> have these error codes. This has yet to be converted into an object file and
> compiled with some code. What do these errors mean? The compiler wants a
> cast and I don't know if I need to convert types use a cast to a similar
> type or what. I've tried both these things. Any ideas?
>
> #include <stdio.h>
>
> #define type unsigned int
>
> struct stk {
> * * type date[6];
> * * type price;
> * * type volume;
>
> };
>
> struct stk s, *ps;
> struct stk packs(type date[6], type price, type volume)
> {
> * * s.date[6] = date[6];
> * * s.price = price;
> * * s.volume = volume;
> * * return s;
>
> }
>
> type unpacks(struct stk * date[6], struct stk * price, struct stk * volume)


Here you claim that "date" is an array of 6 pointers to struct stk.

> {
> * * type date[6];


But here you claim that "date" is an array of 6 unsigned ints.
Which is it?

<snip>
--
Fred K
 
Reply With Quote
 
 
 
 
Bill Cunningham
Guest
Posts: n/a
 
      02-17-2011
Fred wrote:
> On Feb 17, 10:16 am, "Bill Cunningham" <(E-Mail Removed)> wrote:
>> I just about have the code I wanted to write written. It compiles
>> but I have these error codes. This has yet to be converted into an
>> object file and compiled with some code. What do these errors mean?
>> The compiler wants a cast and I don't know if I need to convert
>> types use a cast to a similar type or what. I've tried both these
>> things. Any ideas?
>>
>> #include <stdio.h>
>>
>> #define type unsigned int
>>
>> struct stk {
>> type date[6];
>> type price;
>> type volume;
>>
>> };
>>
>> struct stk s, *ps;
>> struct stk packs(type date[6], type price, type volume)
>> {
>> s.date[6] = date[6];
>> s.price = price;
>> s.volume = volume;
>> return s;
>>
>> }
>>
>> type unpacks(struct stk * date[6], struct stk * price, struct stk *
>> volume)

>
> Here you claim that "date" is an array of 6 pointers to struct stk.
>
>> {
>> type date[6];

>
> But here you claim that "date" is an array of 6 unsigned ints.
> Which is it?
>
> <snip>



 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      02-17-2011
Fred wrote:

> But here you claim that "date" is an array of 6 unsigned ints.
> Which is it?


Hum some kind of conversion is needed here. Thanks for waking me up.

B


 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      02-17-2011
"Bill Cunningham" wrote:

> I just about have the code I wanted to write written. It compiles but I
> have these error codes. This has yet to be converted into an object file
> and compiled with some code. What do these errors mean? The compiler wants
> a cast and I don't know if I need to convert types use a cast to a similar
> type or what. I've tried both these things. Any ideas?
>
> #include <stdio.h>
>
> #define type unsigned int
>
> struct stk {
> type date[6];
> type price;
> type volume;
> };


Rather than fix the problem you are having, I suggest you rethink your
approach.

Draw six boxes, representing the six elements of the array known as date.
Now, pretend computers used decimal instead of binary, and fill in each of
the six boxes as they would look for February 17, 2011. Does the result look
sensible to you? I certainly hope not.


 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      02-17-2011
"osmium" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Rather than fix the problem you are having, I suggest you rethink your
> approach.


Yes, he should stop . . . whatever it is that he's doing.



Brian
--
Day 742 of the "no grouchy usenet posts" project
Current music playing: None.


 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      02-17-2011
Fred wrote:
> But here you claim that "date" is an array of 6 unsigned ints.
> Which is it?


Ok I see. I have corrected my mistake. I overlooked it. Now a word about
scope. I realize and have intentionally in the functions packs and unpacks
used the same names because I understand a type name whether declared as a
parameter or in the function body is local for that function.
struct stk s;

I have left for both functions to share I hope to remain in this .c
file's scope it need not be declared static and I usually don't super
confuse things with externs. The compiler only warns now about shadow types.

B


 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      02-17-2011
osmium wrote:

> Rather than fix the problem you are having, I suggest you rethink your
> approach.
>
> Draw six boxes, representing the six elements of the array known as
> date. Now, pretend computers used decimal instead of binary, and fill
> in each of the six boxes as they would look for February 17, 2011.
> Does the result look sensible to you? I certainly hope not.


My intent was to use a 6 digit format such as 021711. That's why I used
an array of 6.

B


 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      02-17-2011
Default User wrote:
> Yes, he should stop . . . whatever it is that he's doing.


Oh no! No DU! This must not be on topic! When did you ever post anything
that wasn't OT? You never respond to any posters except me and it's always
OT. Let's not start trolling now.

B


 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      02-17-2011
On 02/18/11 11:46 AM, Bill Cunningham wrote:
> Default User wrote:
>> Yes, he should stop . . . whatever it is that he's doing.

>
> Oh no! No DU! This must not be on topic! When did you ever post anything
> that wasn't OT? You never respond to any posters except me and it's always
> OT. Let's not start trolling now.


Pot, kettle?

--
Ian Collins
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with ld: Unresolved error C++ compiling error stevenruiz@gmail.com C++ 2 02-13-2007 09:04 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 1 03-24-2006 04:20 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM
My DVD Error Problems writing on dvd , Error: sense code (37303) , DVD Err, 226051 Bun Mui Computer Support 0 06-18-2004 11:29 AM
problems in vc++:Applying setting user breakpoint, unhandled exception ,linking error,runtime error manish C++ 1 04-02-2004 12:33 PM



Advertisments