Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

i want to stop being a beginner

Name: Anonymous 2007-04-27 12:04 ID:E/HPNyiZ

Yeah so I've taken a few c++ classes at college, up to data structures. But just because I know how to write a bs-tree doesn't mean im an EXPERT PROGRAMMER just yet. The most complicated program I've written so far is one that solves the Towers of Hanoi by brute force. I still consider myself a beginner-level programmer.

Does anyone have any tips on how to improve my skill? Like a large one-man project that will teach me how to write & manage larger programs? Whenever I got the book store and look at the programming sections everything is either TEACH YOURSELF JAVA IN 24 HOURS or like START C++ FOR THE MENTALLY RETARDED. Everything is aimed at beginners but I want to move on.

protips?

Name: Anonymous 2007-05-06 21:03 ID:vQFs9ZNX

>>39

Then use C++ strings, not C strings.

Name: Anonymous 2007-05-06 21:10 ID:3nVRcIU3

>>1
If you wish to learn more about PHP, there are video tutorials here... watch a couple per day, and he'll tell you of a few tools and examples. Again, good luck

http://www.phpvideotutorials.com/

Name: Anonymous 2007-05-06 21:17 ID:/tU/N7M0

>>42
PHP is a shitty language and needs to die.

Name: Anonymous 2007-05-06 21:19 ID:3nVRcIU3

Libraries are built from the ground up on C strings, so even if you work with the C++ string construct, you have to convert them back. Receive input from the user? It's in an array. C++ is polymorphic, but the standard library has not a shred of effort into returning C++ strings based on context. So it's a kludge that could only be "forgotten" by creating new languages like Python and Java, altogether.

The reason I bothered to put the code example is to show how to build up a string, but you end up having to combine C++ and C strings. In some extreme cases you need to use stringbuffer constructs, to pass data around. You'll google a lot just to process a bit of data back and forth, specially if you interact with the Windows API, where you need those pesky LPCTSTR things which are C chars or wchars, instead of C++ based. OS's don't facilitate C++ strings because they're are written in C, even if your code is compiled in C++.

Just sad, really.

Name: Anonymous 2007-05-06 21:24 ID:tY2/Gk1/

>>1
lulz. i've been programming for nearly 25 years and i'm still regard myself a beginner.

there's way too much out there to know it all and be another so-called "expert programmer"...

Name: Anonymous 2007-05-06 21:30 ID:/gmFGX53

#include <iostream>
#include <string>
int main() {
  char bleh[] = "I'm a string!";
  std::string blah(bleh);            // char* to std::string
  std::cout << bleh << std::endl
      << blah << std::endl
      << blah.c_str() << std::endl;  // std::string to char*
  return 0;
}

Name: Anonymous 2007-05-06 21:46 ID:3nVRcIU3

>>46
Thanks. That's good for the console, but not when you have to use that input (instead of just cout.)

Say you append to that a string representation of the time and date, and then send that to an "imported" function that stores the whole thing to a file.

I'm just making a point of real life C++ issues. Most of the time your code doesn't deal with the user directly, and it just deals with other code built by the OS or another company. COUT is for simple programs, intro classes or debugging messages. In the real world, if you can't summon a message box, you have to at least leave a log file with such pre-processed information and timestamps. You build lots of custom strings stating what things were running at the time. This is a pretty good thread. Thanks OP!

Name: Anonymous 2007-05-06 21:55 ID:vQFs9ZNX

Yes, c_str() FTW

Name: Anonymous 2007-05-06 22:00 ID:p727mKpD

>>47
fprintf(stderr,"%ld : Faggotry",time());

Name: Anonymous 2007-05-06 22:05 ID:rkEgVB/i

sprintf(StupidStringBuffer, "%d", IntValue);

Name: Anonymous 2007-05-06 22:31 ID:/tU/N7M0

C99 and asprintf FTW. Fuck C++.

Name: Anonymous 2007-05-06 22:44 ID:Heaven

>>51

GTFO with your proprietary GNU extensions

Name: Anonymous 2007-05-07 8:06 ID:RrBgHOTE

>>52
C99 is not GNU.

Name: Anonymous 2007-05-07 8:29 ID:wHKA8XvG

>>40
protip: sprintf() puts the godamn null byte at the end.
buffer[300] = {0}; is not needed.

>>49 i lold

>>50
Real men write their own function to convert numbers to strings.
Simply because sprintf() is way to much for just a number.

Lastly, here's a PROtip:
If you are going to use sprintf() and the such, to prevent buffer overflows and shit either write a formatted strlen() function (eg size_t strlenf(char *format, ...)) or use malloc and realloc.

Name: Anonymous 2007-05-07 9:15 ID:O1oc4tBf

>>54
if your strlenf is so great why isn't it included in my stdlib?

Name: Anonymous 2007-05-07 9:25 ID:wHKA8XvG

>>55
please tell me you're not serious.

Name: Anonymous 2007-05-07 9:32 ID:O1oc4tBf

>>56
I'm afraid I can't do that

Name: Anonymous 2007-05-07 9:46 ID:wHKA8XvG

>>57
then you're a fucking idiot, it's like saying
"well my stdlib doesn't have a regex function so what's so great about regex ?
TRE is a PoS and nobody needs it, ever!"
Or even
"well why is there a printf() ? what is this faggotry who needs printf? I'm happy with my kernel calls"

Name: Anonymous 2007-05-07 12:03 ID:pe+Zlgx5

>>51 was misunderstood by >>52 and >>53. C99 doesn't include asprintf --the latter's one of those orphan / non-standard functions compilers include for convenience.
>>54 well, using malloc, realloc and free gets back to my point of C strings being written as a high maintenance hell on earth, since you'll at least double the number of string management lines in your code. Writing my own functions might lead to more bugs but it's for brevity, I guess. However, snprintf() IS standard and it already returns the length of the string formatted (minus the null.)

I'm >>44, in case my IP was renewed overnight.

Name: Anonymous 2007-05-07 12:11 ID:yVole8vw

snprintf lol

Name: Anonymous 2007-05-07 23:14 ID:FO0QpMy/

     The functions asprintf() and vasprintf() first appeared in the GNU C
     library.  These were implemented by Peter Wemm <peter@FreeBSD.org>; in
     FreeBSD 2.2, but were later replaced with a different implementation from
     Todd C. Miller <Todd.Miller@courtesan.com>; for OpenBSD 2.3.

Name: Anonymous 2007-05-07 23:56 ID:Y0UmH5bV

you might also want to think about running a linux server for something (asterisk, mythtv, web server etc), you'll learn a lot more about how computers and operating systems work in unix than you will in windows.

Name: Anonymous 2007-05-08 0:54 ID:C7c1jN36

>>62 Yup. There's some money in learning (open source) asterisk, I hear from our telephony guy. I'm not sure what hardware you need, since IP telephony would need IP phones, or some kind of ethernet to plain old phone conversion somewhere.

There's a live MythTV CD around. I own a copy, but I think it failed to boot my only computer (a laptop, so it's reasonable and it lacks the Video Decoder needed for what I hear MythTV does.) Web servers, though, in themselves I find a bit overrated. They pretty much run themselves, while you spend the real money on the developers who upgrade your web applications and such. Matter of fact, in the US, I know civil servants who do less in their daytime college web administration tasks daily than you'd do in the bathroom lacking toilet paper. When they're not fixing Oracle or the linux mailer services, they update the schema for the school's hardware or class databases. Students have a selection interface through PHP that they work on. So they keep the server up, but the real work goes in the webpage upgrades / student notices.

Name: Anonymous 2007-05-08 1:17 ID:i5wcX6ln

>>1
if you don't want to be like >>36 ("switch from DOS C++ into real world C++ with QT, MFC or whatever, so that you can get hired", "I myself am trying to learn the win32 API, but it really sucks. That would be too advanced."), buy a book about unix, install unix os on your system (linux would be a great choice), and try to mess with it.

Name: Anonymous 2007-05-08 4:35 ID:PTIVV4iy

>>40
Fact:

If the first element in an aray of T is nonzero the rest of the array is initialized.

Name: Anonymous 2007-05-08 5:03 ID:ZDrUH4iK

You are kidding arent you ? That sounds preposterous to me. I think you need to re-examine your assumptions.

Name: Anonymous 2007-05-08 5:35 ID:v4JHuSae

where is it initialized you prick?

$ cat <<HERE>hello.c
#include <stdio.h>
>
int main(int argc, char** argv)
{
char buffer[300] = {12};
sprintf(buffer, "you lie");
}
>
HERE
$ gcc hello.c -S
$ cat hello.s
        .file   "hello.c"
        .def    ___main;        .scl    2;      .type   32;     .endef
        .data
LC0:
        .byte   12
        .space 299
        .section .rdata,"dr"
LC1:
        .ascii "you lie\0"
        .text
.globl _main
        .def    _main;  .scl    2;      .type   32;     .endef
_main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $344, %esp
        andl    $-16, %esp
        movl    $0, %eax
        addl    $15, %eax
        addl    $15, %eax
        shrl    $4, %eax
        sall    $4, %eax
        movl    %eax, -316(%ebp)
        movl    -316(%ebp), %eax
        call    __alloca
        call    ___main
        leal    -312(%ebp), %ecx
        movl    $LC0, %edx
        movl    $300, %eax
        movl    %eax, 8(%esp)
        movl    %edx, 4(%esp)
        movl    %ecx, (%esp)
        call    _memcpy
        movl    $LC1, 4(%esp)
        leal    -312(%ebp), %eax
        movl    %eax, (%esp)
        call    _sprintf
        leave
        ret
        .def    _memcpy;        .scl    3;      .type   32;     .endef
        .def    _sprintf;       .scl    3;      .type   32;     .endef
$

Name: Anonymous 2007-05-08 7:29 ID:Heaven

>>40
Troll troll is troll. Gtfo.

Name: Anonymous 2007-05-10 0:09 ID:texCOCpz

>>64 (>>36 here) Getting linux doesn't have to be a computer-wipe away. If you don't want to repartition, you can use a Live-CD. Ubuntu, Mandriva, Knoppix and other flavors (http://distrowatch.com's sidebar on the right has 100 links to download ISO's) have "boot-from-CD and leave hard drive alone" technology. Matter of fact, you can't save things unless you have a USB memory stick handy, for, say, saving code you wrote while under the live boot.
>>65 Thanks. I swear I learned this somewhere, and it wasn't for virtual function initialization --it was someone's C code.

Name: Anonymous 2007-05-10 12:10 ID:SYoyIvaC

>>65
>>69
Pleas elaborate.
The "If the first element in an aray of T is nonzero the rest of the array is initialized." is bullshit.

Name: Anonymous 2007-05-10 21:10 ID:texCOCpz

>>70
>>69 here. It may be one of those conditions where it's up to the implementor to decide. Seems sound to me, in the context it was mentioned. I'm starting to have suspicions, but there was assembly code and I don't care enough to test it myself.

I just know that in the dozens of lines that say something like char name[255] = new char[255], I once saw {0} instead, recently. I probably also saw it in a NES emulator with a struct initialization, but it could just be a false memory.

Name: Anonymous 2007-05-10 23:19 ID:Heaven

GCC initializes all fields to zero if you use {0}. I have no idea about nonzero though.

Name: Anonymous 2007-05-11 0:07 ID:fLldn5g+

>>72 Thanks. This thread has turned obscure. I wonder if the original poster is still reading this, as it's been two weeks. I only noticed the thread this past weekend, and have been on /prog/ very often for help, learning and "master programmer" comments. Been fun.

Name: Anonymous 2007-05-11 0:43 ID:E1OpkpER

>>73
EXPERT PROGRAMMER

Name: Anonymous 2007-05-11 4:53 ID:p/a5v5gD

>>72
It doesn't. See >>67

Name: Anonymous 2007-05-11 6:28 ID:FvjwZXRW

>>67

Look more closely. This initializes the 300 bytes at LC0 as {12,0,0,0,0,0,...}:

LC0:
        .byte   12
        .space 299


(see http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_node/as_124.html for why)

And this copies them to the char buffer that has been allocated on the stack:

        leal    -312(%ebp), %ecx
        movl    $LC0, %edx
        movl    $300, %eax
        movl    %eax, 8(%esp)
        movl    %edx, 4(%esp)
        movl    %ecx, (%esp)
        call    _memcpy

Name: Anonymous 2007-05-16 2:11 ID:GeVDperO

Go get a degree from a good university.

Name: Anonymous 2007-05-16 2:33 ID:Heaven

Quit aging ancient threads.

Name: Anonymous 2007-05-16 12:16 ID:DY7Op3ba

>>78
Why?

Name: Anonymous 2007-05-16 12:47 ID:LkX0fijR

put your mouth on my penis PRZ

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List