re:return a string



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;
}

.



Relevant Pages

  • Re: Need help understanding program control/flow.
    ... Once one of them is executed, the execution continues ... int display_instructions; ... void display_report; ... Purpose: This function gets the data from the user. ...
    (comp.lang.c)
  • Re: Need help understanding program control/flow.
    ... "if" is not a loop construct. ... int display_instructions; ... void display_report; ... Purpose: This function gets the data from the user. ...
    (comp.lang.c)
  • Need help understanding program control/flow.
    ... int display_instructions; ... void display_report; ... cont = display_instructions; ... Purpose: This function gets the data from the user. ...
    (comp.lang.c)
  • Re: size of pointer variables
    ... In theory the size of a char* and a int* can be different. ... and I don't think it's very common. ... The purpose of the void* ... You can always be shure that a void* will ...
    (comp.lang.c)
  • Help in Java swings(internal Frame)
    ... public int getSize() ... public void valueChanged{ ... private JScrollPane scrollPane1; ... public class PeakContainer extends JInternalFrame ...
    (comp.lang.java.programmer)