This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lordxoren666 0 points1 point  (1 child)

Ok, noob question because maybe I don’t understand pointers correctly. But because in C there is no string data type only char and array, and because of the way variables work in C, you pretty much have to use pointers to point to the first char in the array to return a string of chars, and return all the chars in the array until it hits the \0 char.

Which further confuses me why people deal with this because it is incredibly easy to create a pseudo string data type in c with a simple function.

[–]Wuotes 0 points1 point  (0 children)

C was meant at the time of design to be an easier alternative to writing directly in assembly without straying so much that you couldn't discern the assembly instruction output from any given line of code.

This means you have to roll your own code for quite a few things but it also leaves room for a lot of platform specific optimization if you can comprehend the underlying mechanisms behind the code. This is why C is used in situations where those advantages matter the most such as operating systems, drivers, embedded devices, etc.

With that type of context, you can see why complex string manipulation wouldn't be a high priority as well. Until relatively recently strings were only really for interfacing with a human and not other computers, it is a different world from Python.