Hello, I was considering learning C++ from the start, but someone told me I should have a pretty good handle on the basics at a minimum of C before I start messing with C++.
I figured C++ was an extension of C, so it sounded good to me. You don't think I need to learn C first? Thanks, Andre On Tue, Oct 28, 2008 at 6:19 PM, Tyler Littlefield <[EMAIL PROTECTED]>wrote: > >Personally, I'd not even bother with C and use C++ instead, it has a > >string class which is much easier to use (and you can do stuff in C++ > >with container classes than can do things similar to Perl arrays and > >hashes). > I would recommend learnning how the string manipulation works though; it > will help, and the standard library functions can be sped up by rewrites. > > Thanks, > Tyler Littlefield > email: [EMAIL PROTECTED] <tyler%40tysdomain.com> > web: tysdomain-com > Visit for quality software and web design. > skype: st8amnd2005 > > ----- Original Message ----- > From: Brett McCoy > To: [email protected] <c-prog%40yahoogroups.com> > Sent: Tuesday, October 28, 2008 4:16 PM > Subject: Re: [c-prog] Newbie Newbie C question > > On Tue, Oct 28, 2008 at 6:07 PM, Andre Fecteau <[EMAIL > PROTECTED]<andre.fecteau%40gmail.com>> > wrote: > > > I'm really new to c programming, so bear with my simple question. I'm a > > Perl programmer, who has just started learning C(not even experienced > > at Perl). I can get around and usually manage through lots of work to get > > what I need done, done! In Perl I can assign a string to an array > element. > > > > ex: $array[0] = "example"; > > > > > > In C it seems that you can only assign an individual letter to each > element. > > > > ex: array[0] = 'c'; > > > > Whenever I try to do what I do in Perl all the time, in c I get compile > > errors. What am I doing wrong? > > Can I even do this in c? > > > > If you can't do that in c, that's OK. It's just really convenient to do > it > > the Perl way! > > Yay Perl! (I'm a big Perl geek also) > > It can be done in C, it just takes a little more work. If you want to > declare an array of strings, you will do something like > > char *str_array[10]; > > then you must allocate memory for each array item (using malloc) and > then copy your string into each array element > > strcpy(str_array[0], "example"); > > There are things you can do to make the code more robust (like > verifying the string you are copying is not too long for the allocated > memory, etc). String manipulation is not too fun in C and much more > fun in Perl. > > Personally, I'd not even bother with C and use C++ instead, it has a > string class which is much easier to use (and you can do stuff in C++ > with container classes than can do things similar to Perl arrays and > hashes). > > One thing you should look into learning and using is the pcre library > for C & C++ -- Perl Compatible Regular Expression library! > > -- Brett > ---------------------------------------------------------- > "In the rhythm of music a secret is hidden; > If I were to divulge it, it would overturn the world." > -- Jelaleddin Rumi > > [Non-text portions of this message have been removed] > > > -- Andre Fecteau Mobile Computer Geeks 843-906-6070 [Non-text portions of this message have been removed]
