From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Mariano Moreyra" Subject: RE: const char * vs char[] Date: Tue, 23 Mar 2004 10:44:36 -0300 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <000701c410dc$fb457820$0c81640a@aca.org.ar> References: <20040323130118.00005637.cialdi@firenze.net> Reply-To: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20040323130118.00005637.cialdi@firenze.net> List-Id: Content-Type: text/plain; charset="us-ascii" To: 'Massimiliano Cialdi' , 'linux-c-programming' I think that the problem is not a difference between "char*" and "char[]" The problem is that stampa is receiving a "char[]" and you are passing a "const char*" as the arg. The "qualifiers from pointer targer type" refers to the "const" part of the "const char*" declaration I belive. If you declare stampa like this: void stampa(const char s[]); you won't have this warning anymore. -----Mensaje original----- De: linux-c-programming-owner@vger.kernel.org [mailto:linux-c-programming-owner@vger.kernel.org]En nombre de Massimiliano Cialdi Enviado el: Martes, 23 de Marzo de 2004 09:01 Para: linux-c-programming Asunto: const char * vs char[] I have this: #include const char *str = "pippo"; int main(void) { void stampa(char s[]); stampa(str); return 0; } void stampa(char s[]) { printf("%s\n", s); } and gcc gives me a warning: pippo.c:9: warning: passing arg 1 of `stampa' discards qualifiers from pointer target type what are the differences between char[] and const char *? thanks -- Massimiliano Cialdi cialdi@firenze.net m.cialdi@oksys.it - To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html