Started work on functions and arrays these last two weeks. Question.
Strings = a complex array?
A lot of class now is spent less with notes and more with short, simple programs as illustration, which I cannot emphasize enough how awesome that it, though it does reinforce my inability to do a damned flowchart or IPO. Anyway. I was looking at strings, since they have their very own include to be added as a data type--was that written so that there wouldn't necessarily be arrays for stuff like entire paragraphs? And how are those created?
I'm curious. I've been playing with functions a lot to see how they shorten a program, and the arrays feel very--interesting, yes, but also interestingly *useful*. Though I'm not sure how yet.
Seriously, I only have two weeks left, and I'm already missing this class a lot. I really wish they had a Christmas short semester.
Sadly, we are skipping two dimensional arrays. It is depressing.
You know, eventually, I have got to think of something more interesting to say.
Strings = a complex array?
A lot of class now is spent less with notes and more with short, simple programs as illustration, which I cannot emphasize enough how awesome that it, though it does reinforce my inability to do a damned flowchart or IPO. Anyway. I was looking at strings, since they have their very own include to be added as a data type--was that written so that there wouldn't necessarily be arrays for stuff like entire paragraphs? And how are those created?
I'm curious. I've been playing with functions a lot to see how they shorten a program, and the arrays feel very--interesting, yes, but also interestingly *useful*. Though I'm not sure how yet.
Seriously, I only have two weeks left, and I'm already missing this class a lot. I really wish they had a Christmas short semester.
Sadly, we are skipping two dimensional arrays. It is depressing.
You know, eventually, I have got to think of something more interesting to say.
no subject
From:2D Arrays are sort of like an array within an array. I think strings were slightly different to a complex array. But I'm pretty sure all the knowledge I had of Java evaporated after my exam, so I cant be certain!
(- reply to this
- thread
- link
)
no subject
From:(- reply to this
- parent
- top thread
- link
)
no subject
From:(- reply to this
- thread
- link
)
no subject
From:(- reply to this
- parent
- top thread
- link
)
no subject
From:(- reply to this
- parent
- top thread
- link
)
Warning: geek-out ahead
From:Depends on the language, and if it's involved, the database. And the two may not deal with strings the same way. Afaik, these are the ways a string can be stored:
- an array (either exposed to the developer or not).
- a fixed length piece of data that consists of one character after another.
- a piece of data of length n that begins with a character count.
- a piece of data of unspecified length that begins with a special start character and ends with a special end character.
And depending on the language, the array may be stored in any of the last three ways, or as a linked list. (But I don't think they teach linked lists anymore.)
It doesn't hurt to think of them as arrays, most languages allow you to work with the characters as if the string was an array.
(- reply to this
- thread
- link
)
Re: Warning: geek-out ahead
From:This does conveniently explain why soem programs have character limits when entering names. I think.
(- reply to this
- parent
- top thread
- link
)
Strings???
From:(- reply to this
- thread
- link
)
Re: Strings???
From:(- reply to this
- parent
- top thread
- link
)
no subject
From:http://en.wikipedia.org/wiki/C_string
(- reply to this
- thread
- link
)
no subject
From:Fascinating. *mulls*
(- reply to this
- parent
- thread
- top thread
- link
)
no subject
From:Stacks are a lower level form of array that don't have the niceties built in.
(- reply to this
- parent
- top thread
- link
)
Why oh why are there different data types?
From:This is my hazy remembering from the dawn of time.
Seriously, I got my Computer Science degree in 1983 -- I started programming in ...huh...1976? Maybe? (oh, in the essence of full disclosure, I stopped in 1989 when I went back to school to study Psych. But I was systems level programmer for a large corporation for 5 years after graduation, and I have been enjoying reading about your glee at your classes. You are the first person to tempt me to go back & retake a class or two)
/mybrainhurtsfromthinkingaboutprogramming...thunk/
(- reply to this
- thread
- link
)
Re: Why oh why are there different data types?
From:(- reply to this
- parent
- thread
- top thread
- link
)
Re: Why oh why are there different data types?
From:umm,err, then I remembered that it was the plastic ruler-like flow chart drawing aids that I adored.
I'm pretty sure I never, ever wrote a flowchart before a program through my entire college career. (i'd do the program first, then make a flowchart to hand in).
I'm pretty sure I never did a flowchart during my entire RL career, either. (unless I had to explain a programming concept to somebody).
Ironically, I've written pseudo-flowcharts to design systems in non-programming environments quite often (they are especially helpful to chart typical crisis call scenarios).
My favorite part of college? Really really obscure programming languages. (My main language was FORTRAN, which unless you loaded it with comments to explain what was happening was onoy understandable to people who knew the language).
But my favorite of all languages -- APL. (literally stood for "A Programming Language" and was all symbols. Not normal alphanumeric characters, but symbols. Heh).
Oh oh -- and LISp. (aka: Lots of Irritating Parentheses). I actually programmed in LISp for the last year of my career, which is why, to this very day, I have to close off any/all embedded parentheses (when I make asides within asides (which I love to do (cause it's fun fun fun))).
:-D
(- reply to this
- parent
- thread
- top thread
- link
)
Re: Why oh why are there different data types?
From:(- reply to this
- parent
- top thread
- link
)
no subject
From:I see in the comments you seem to be conflicting answers. Are you talking about regular strings or C-strings? Because in the case of c-strings this is definitely the case as c-strings are character arrays. However, on the regular data type string I am not so sure as to how they are actually allocated in memory, but my instinct is to say no that strings are probably a class.
was that written so that there wouldn't necessarily be arrays for stuff like entire paragraphs? And how are those created?
I don't know but that is a very interesting question. I am assuming it was written because c-strings are actually pointers* that point to a character array and therefore all normal operations(=,+,-, >, <) don't work as you would expect them to. I am assuming that what is written in the include is what fixes this to where they perform as expected.
*Have you gotten to pointers yet? They let you dynamically allocate the size of the array based of something else(user input, size, ect). So cool.
I am sure you have learned this but the first rule of arrays is: for loops are your best friend. (for(int i = 0; i > size; i++){})
(- reply to this
- thread
- link
)
no subject
From:There's a small typo :)
It should be for (int i=0; i < size; i++) {}
(- reply to this
- parent
- top thread
- link
)