Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Not sure what you found out, but strings actually are arrays of characters (in most languages). What did you find out to think otherwise ?
-
setleaf2748y@thecritic Well quite a few people replied saying strings were actually very complex classes and not simply arrays of characters. The language was C++ by the way.
-
Pure C strings are actually arrays of characters "char *" (a pointer to a character in memory). They are stored in contiguous memory so that you can basically jump from character to character until the null terminator (last character is '\0') which esentially forms a string. C++ added string utilities, but at the very core I am very sure that they are represented in very much the same way. C++ just aimed to make developers' lives easier by providing that whole string library.
-
setleaf2748y@thecritic Interesting! I wonder how they implement it as an array of characters in C++ since arrays can't be of variable length, but you can add characters onto a string changing the size of the array?
-
Arrays in C/C++ can actually have variable length. You can actually allocate memory on the heap and mess around with that memory how you like, that's one beautiful aspect of the language. I think you need to get your feet wet a little more before you judge your teachers/professors.
-
setleaf2748y@thecritic I wasn't aware of the fact you could have variable length arrays.
To give the full story, I emailed my professor with a thorough explanation of a problem and asked for guidance. He responded with he wasn't sure what the problem was, so I posted the exact same thing in stack overflow and had multiple people tell me that something he had told us in class wasn't correct, WHILE actually giving me an in-depth explanation and answer to my issue....for free....hence my rant. -
flag020328y@setleaf if your professor said that and he replied with "I don't know that" instead of some B's, you're in good hands
-
@setleaf It's okay, it just hurts my heart a little bit sometimes when people post misleading information. No hard feelings, just wanted to set the record straight on the strings that's all.
When a professor says, "strings are an array of characters" and you proceed to post a question on stack overflow containing the phrase, "strings are an array of characters" and get a healthy dose of knowledge about what strings actually are....
I'm paying for this education?
undefined