PDA

View Full Version : Attempting to learn C with my friend's help


JadussD
02-07-2004, 10:11 PM
So I made a C program with my friend's help that generates an HTML file with an album review. The user inputs the Artist, Album, Year, Genre, then a review of the album and then the filename it's to be saved to. I suppose something like PHP would be better suited for this, but setting up all the shit you need to get started on PHP looked like a daunting task, and I didn't exactly find solid, good information on how to do this. Anyways, it was pretty fun trying to code in a language I know nothing about while periodically shouting across the room at my friend...

ME: Okay, I need this to check to see if the user actually inputted data, how the hell do I do this? Some kind of loop, I'd assume [paging through a 1988 version of 'Learn C Now!"]

HIM: Well, you _could_ use goto...

ME: goto? Isn't it the general consensus that goto is gay or something?

HIM: Well, it IS frowned upon...

ME: Okay, how about do/while or whatever...

...

ME: Ugh, what the fuck is wrong with my while loop?

HIM: Oh, you put a semi-colon at the end. You don't do that with while.

ME: Ahhh, I see, because of the braces and all that. Ah! Okay.

...

ME: This isn't fucking working. How about do/while instead of just while?

HIM: Well, that's kind of unnecessary...

ME: [thinking about what do/while does compared to while] Ahhh...so "do" is gay, right?

HIM: Well, it's not _gay_, but there really aren't that many situations where I've needed to use it...

ME: Ahhhh! I see why it skips the field for Artist, if you use scanf for input, it's gay and it doesn't allow for spaces! Aha! "gets" is better, because it does not do that! I figured it out all by myself!

HIM: Ah.

<P ID="signature"><HR>
<CENTER>http://members.aol.com/jadussvii/ea.jpg</center></P>

Octocrook
02-07-2004, 11:41 PM
> HIM: Well, it's not _gay_, but there really aren't that many
> situations where I've needed to use it...

Probably one of the many reasons why I will probably never become a programmer. Essentially, for and do while loops, 2 of the loops that I use the most, are not necessary. A for loop is just an abbreviated while loop, and a do while loop is something you can do by making the while loop go through only once. I love do while loops though...if I want to force a loop through one time, and have a loop condition that is contingent upon something inside the loop, then I use do while. I don't care what other programmers think!

Goto on the other hand is gay, mainly for the reason that it disrupts a program's top-to-bottom flow, possibly making it confusing. You can use it, but if you ever want anyone else to look at your code and help you with it, then you probably don't want to use it.

<P ID="signature"><img src=http://www.crooky.us/csig.jpg>
<a href=http://www.crooky.us/mp3.htm>Download "End of the World" here</a>

<center><a href=http://www.crooky.us>Crooky.us</a></center></P>

Crazy_MYKL
02-08-2004, 12:02 AM
> I love do while loops though...if I want to
> force a loop through one time, and have a loop condition
> that is contingent upon something inside the loop, then I
> use do while. I don't care what other programmers think!

There is nothing wrong with do while, and goto has uses, especially to escape from deep loop nests. And for loops should always be used... FOR GREAT JUSTICE!!

<P ID="signature"></P>

SirDaShadow
02-08-2004, 12:09 AM
> There is nothing wrong with do while, and goto has uses,
> especially to escape from deep loop nests. And for loops
> should always be used... FOR GREAT JUSTICE!!
Don't you mean break instead of a goto?


<P ID="signature"></P>

Crazy_MYKL
02-08-2004, 12:27 AM
> > There is nothing wrong with do while, and goto has uses,
> > especially to escape from deep loop nests. And for loops
> > should always be used... FOR GREAT JUSTICE!!
> Don't you mean break instead of a goto?
>
Depends on conditions. Gotos should be avoided, unless it would be far more convulted to do it any other way.

<P ID="signature"></P>

MooglyGuy
02-08-2004, 01:06 AM
> Depends on conditions. Gotos should be avoided, unless it
> would be far more convulted to do it any other way.

If it's more convoluted to not use goto then there is something seriously wrong with the structure of the rest of your code.

<P ID="signature">http://www.zophar.net/Files/mooglish.png
"Kupo, motherfucker!! DO YOU SPEAK IT!?"</P>

Crazy_MYKL
02-08-2004, 02:16 AM
> If it's more convoluted to not use goto then there is
> something seriously wrong with the structure of the rest of
> your code.
>
Or it's just VERY complex, but I agree gotos are to be avoided in all but the most extreme of circumstaces. Goto considered harmful.

<P ID="signature"></P>

icenine0
02-08-2004, 11:55 PM
Y'all are spoiled sons a bitches! Back in the days of GWBASIC, we had nothing but our gotos and we liked em' dagnabbit!

> Or it's just VERY complex, but I agree gotos are to be
> avoided in all but the most extreme of circumstaces. Goto
> considered harmful.

<P ID="signature">The more often you fail, the sweeter the taste of success!</P>

shawn
02-09-2004, 01:51 AM
> Y'all are spoiled sons a bitches! Back in the days of
> GWBASIC, we had nothing but our gotos and we liked em'
> dagnabbit!

Hell I use a proprietary version of basic to program the cnc drill/router at work. We edit the programs using XTGold running on DOS. <img src=smilies/magbiggrin.gif>

<P ID="signature"></P>

IceWolf20
02-09-2004, 01:23 PM
> Hell I use a proprietary version of basic to program the cnc
> drill/router at work. We edit the programs using XTGold
> running on DOS.

Can I get a 'hell yeah' for proprietary versions of BASIC...w00t! Just kidding, I fucking hate this awful UniBASIC-esqe language we use...fortunately there are no GOTO's but there are a ton of GOSUB's....oh well.


<P ID="signature"><div align="center">http://stuorgs.lvc.edu/acm/_private/ZMD.gif
...the way to be!</div></P>