Re: Another Understanding Pointers Question

From: Robert Bachmann (Robert.Bachmann_at_rbdev.net)
Date: 05/10/04


Date: Mon, 10 May 2004 18:08:43 +0200

Materialised wrote:

> Hi everyone,
> I seen the post by Rob Morris, and thought that I would double check
> that I was using pointers in the correct way. So I written the following
> string functions to test. I know soem can be iumplimented using the
> standard libary, but I just wanted to test writing my own functions.
> They work ok, but I would like some feed back on any issues you can see
> with them etc

Just a minor note on your use of int.
As far as I think your string functions
will never work with negative values.
So you may want to consider using size_t instead.

> char *left(char *string, int count)
char *left(const char *string, size_t count)

etc.

Best regards,
  Robert Bachmann

-- 
Robert.Bachmann@rbdev.net |) |)
http://rb.rbdev.net       |\.|).


Relevant Pages

  • Re: Another Understanding Pointers Question
    ... > string functions to test. ... but I just wanted to test writing my own functions. ... > int main ... Sorry if thats a dumb question.. ...
    (comp.lang.c)
  • Re: trim function dumping core
    ... I am not sure what should be the behaviour of l/r/all trim against NULL ... ptr, on my sys is Seg Fault. ... char* trim ... It is up to the caller to ensure against NULL pointers passed to string functions, ...
    (comp.lang.c)
  • Re: Break Word
    ... > How can i detect after submitting if any word ... > If so, break it at the 14th char, add a dash, ... http://www.php.net/manual -> string functions. ...
    (comp.lang.php)
  • Re: Comment on trim string function please
    ... Why not return a char *, like most other string functions? ... char *TrimCString(char *str) ... Maybe use memmoveinstead of the loop. ...
    (comp.lang.c)
  • Re: newbie help
    ... In addition to what Igor posted, you will also want to use TCHAR instead of char and the appropriate string functions that also start with _t... ... If you use these macros you will be able to compile your program either for ANSI or Unicode so it's a good idea to just get in the habit of using them rather than just typing in the strings. ...
    (microsoft.public.vc.language)