Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

johnnyBravo

Anything bad about using char [] in functions?

This topic is 5229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, for this function:
void myFunc(char name[])
{
   OutputDebugStringtheName(name);
}
is there any thing bad about putting the ''name'' as ''char name[]''?? Like i won''t cause any problems with memory will i? thanks,

Share this post


Link to post
Share on other sites
Advertisement
If I''m not mistaken, that''s the same as using a char* as the argument.

I don''t recommend doing this, as it''s very easy to make mistakes (off-by-1 errors, forgetting a ''\0'', null-pointers, etc.). As long as the string is null-terminated, though, you should be okay.

Share this post


Link to post
Share on other sites
If you''re programming in C++, you should generally use the standard C++ std::string type. If you''re programming in C, you don''t have much of a choice.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan (C programming language co-inventor)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!