re:return a string
- From: muzgocrust@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (iru_muzgo)
- Date: Fri, 29 Apr 2005 21:45:55 +0000 (UTC)
Nascimento,
you cannot assign a char to a string like that:
tralha = "#"
you can do it like this: tralha[0]='#';
A more elegant code for your purpose goes like this:
--- tralha.c ---
void
ptr_tralha(char *s)
{
while (*s != '\0') /* while the contents of s are different
* from NULL */
*s++ = '#'; /* s = '#' . increment s */
}
int
main(void)
{
char s[5];
ptr_tralha(s);
puts(s);
return 0;
}
.
- Follow-Ups:
- re:return a string
- From: Emmanuel Delahaye
- Re: return a string
- From: Keith Thompson
- re:return a string
- Prev by Date: Re: main(int argc, char *argv[])
- Next by Date: Re: return a string
- Previous by thread: Re: return a string
- Next by thread: Re: return a string
- Index(es):
Relevant Pages
|