🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
2 messages
2 total messages Started by Michael De Nil Mon, 30 Jun 2003 09:36
Warning bij matrix als arg in C
#4901
Author: Michael De Nil
Date: Mon, 30 Jun 2003 09:36
46 lines
1957 bytes
hey

ik heb volgende code:

...
#define MAX_INPUT 40
int fetch_vars(char *host, char *user, char *pass, char *database, char
*type, char **subtype);
...
int main()
{
    int err=0;
    char host[MAX_INPUT];
    char user[MAX_INPUT];
    char pass[MAX_INPUT];
    char database[MAX_INPUT];
    char type[MAX_INPUT];
    char subtype[10][MAX_INPUT];
    MYSQL mysql_id;

    if(err==0)
        err = fetch_vars(host, user, pass, database, type, subtype);
...
}
...


code werkt perfect, enkel krijg ik een warning tijdens het compilen:

input.c:29: warning: passing arg 6 of `fetch_vars' from incompatible
pointer type


het gaat dus over die laatste pointer (naar die matrix).
kan me iemand vertellen hoe ik dit proper oplos ?



alvast bedankt

michael

--

Michael De Nil --- michael@flex-it.be
Linux lisa.flex-it.be running 129 days
Re: Warning bij matrix als arg in C
#4903
Author: Aquila
Date: Mon, 30 Jun 2003 10:55
33 lines
2029 bytes
Michael De Nil wrote:

> hey
> 
> ik heb volgende code:
> 
> ...
> #define MAX_INPUT 40
> int fetch_vars(char *host, char *user, char *pass, char *database, char
> *type, char **subtype);
> ...
>     char subtype[10][MAX_INPUT];
> ...
>         err = fetch_vars(host, user, pass, database, type, subtype);
> ...
> 
> 
> input.c:29: warning: passing arg 6 of `fetch_vars' from incompatible
> pointer type
> 
Mij lijkt het dat je een verkeerd type geeft: subtype is array van char, dus
char*, en in je functie declareer je dat argument als char**.
Je moet dus ofwel je functieargument aanpassen met een * minder, of in je
oproep een & zetten: 
err = fetch_vars(host, user, pass, database, type, &subtype);

C is lang geleden, het is een beetje op de C++ manier bekeken, maar ik dacht
dat de typesyntax overeen kwam...
-- 
Pleased to meet you
Hope you guess my name
But what's puzzling you
Is the nature of my game
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads