Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #86564
| From | JiiPee <kerrttuPoistaTama11@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | How do C -programmers do reliable string handling? |
| Date | 2022-09-24 20:22 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <tgnedd$31bvi$1@dont-email.me> (permalink) |
I have done C++ since 1997. I personally do not understand why use C if
C++ is extented C and has more in it (and thats why I immediately
swiched from C to C++ when I found C++).
But language-fight aside :) .. I have a serious/honest question:
What is the best way to represend a string in C language? How do best C
programmers represend a string?
Because I am worried that that the length of the string is not
"protected" as there is no private in C language.
In C++ it is well protected and safe something like this:
class String {
// all access functions
private:
int m_lenght;
};
So, it is basically impossible to have a wrong lenght value for a string.
Am I right that C programmers do it something like:
struct String {
char* data;
int lenght;
};
but obviously somebody might put: lenght = 99999999999, and then its
going bad....
How do C programmers make string safe that the above problem does not
occur (that the lenght of the string goes wrong)?
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-24 20:22 +0300
Re: How do C -programmers do reliable string handling? Bo Persson <bo@bo-persson.se> - 2022-09-24 21:00 +0200
Re: How do C -programmers do reliable string handling? Gawr Gura <gawrgura@mail.hololive.com> - 2022-09-24 12:29 -0700
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-25 00:47 +0300
Re: How do C -programmers do reliable string handling? Muttley@dastardlyhq.com - 2022-09-25 08:50 +0000
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-25 13:37 +0300
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-25 13:38 +0300
Re: How do C -programmers do reliable string handling? Bonita Montero <Bonita.Montero@gmail.com> - 2022-09-25 13:34 +0200
Re: How do C -programmers do reliable string handling? Bonita Montero <Bonita.Montero@gmail.com> - 2022-09-25 17:00 +0200
Re: How do C -programmers do reliable string handling? Muttley@dastardlyhq.com - 2022-09-25 15:14 +0000
Re: How do C -programmers do reliable string handling? Gawr Gura <gawrgura@mail.hololive.com> - 2022-09-25 09:22 -0700
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-26 01:01 +0300
Re: How do C -programmers do reliable string handling? Richard Damon <Richard@Damon-Family.org> - 2022-09-25 19:02 -0400
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-26 07:27 +0300
Re: How do C -programmers do reliable string handling? Muttley@dastardlyhq.com - 2022-09-26 15:19 +0000
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-26 21:53 +0300
Re: How do C -programmers do reliable string handling? Richard Damon <Richard@Damon-Family.org> - 2022-09-26 20:42 -0400
Re: How do C -programmers do reliable string handling? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-09-26 17:54 -0700
Re: How do C -programmers do reliable string handling? Muttley@dastardlyhq.com - 2022-09-27 09:36 +0000
Re: How do C -programmers do reliable string handling? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-09-27 15:28 +0100
Re: How do C -programmers do reliable string handling? Gawr Gura <gawrgura@mail.hololive.com> - 2022-09-25 16:34 -0700
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-26 07:32 +0300
Re: How do C -programmers do reliable string handling? Juha Nieminen <nospam@thanks.invalid> - 2022-09-26 08:33 +0000
Re: How do C -programmers do reliable string handling? Paavo Helde <eesnimi@osa.pri.ee> - 2022-09-26 12:18 +0300
Re: How do C -programmers do reliable string handling? Juha Nieminen <nospam@thanks.invalid> - 2022-09-26 09:47 +0000
Re: How do C -programmers do reliable string handling? Gawr Gura <gawrgura@mail.hololive.com> - 2022-09-26 07:40 -0700
Re: How do C -programmers do reliable string handling? Paavo Helde <eesnimi@osa.pri.ee> - 2022-09-24 23:04 +0300
Re: How do C -programmers do reliable string handling? JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-09-25 00:44 +0300
Re: How do C -programmers do reliable string handling? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-09-26 02:03 -0700
csiph-web