Rock's cpp truck.

Rock's cpp truck.

Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
So since I've been working on learning C++, I figured I'd make a truck so I can ask questions, as well as release any projects that I finish. So to start off, I have this question...

Can I nest an if/else statement inside an if/else statement? It would look something like this...
code

cout << "blah blah blah, yes or no?";
if (yes)
{
cout << "yada yada yada, yes or no?";
if (yes)
cout << "you chose yes";
else
cout << "you chose no";
}

else
{
cout << moo moo moo, yes or no?";
if (yes)
cout << "yeah son";
else
cout << "nahh boy";
{



Would that work?
 
 
 
2010 Apr 26 at 14:23 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
It would work if you used the tab button.

Cplusplus code

cout << "blah blah blah, yes or no?";
if (yes)
{
cout << "yada yada yada, yes or no?";
if (yes)
cout << "you chose yes";
else
cout << "you chose no";
}

else
{
cout << moo moo moo, yes or no?";
if (yes)
cout << "yeah son";
else
cout << "nahh boy";
}
 
 
 
2010 Apr 26 at 15:17 UTC — Ed. 2010 Apr 26 at 15:19 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
Yes, it's called "nested ifs". You can do the same with select...case (it's switch...case in Java, think it's select in C++).

And sprinkles is right, formatting is very important. Good to see someone else using that style - I'm not a fan of the K&R/Java style:
Java code

try {
do {
something()
} while (something_else() )
}
catch (Exception e) {
ohshit!()
}


Not for me likes.
 
 
 
2010 Apr 26 at 15:36 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Down Rodeo said:
Yes, it's called "nested ifs". You can do the same with select...case (it's switch...case in Java, think it's select in C++).

And sprinkles is right, formatting is very important. Good to see someone else using that style - I'm not a fan of the K&R/Java style:
Java code

try {
do {
something()
} while (something_else() )
}
catch (Exception e) {
ohshit!()
}


Not for me likes.



Java has try{} catch{} statements?
Didn't know that.
 
 
 
2010 Apr 26 at 15:59 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
Not only does it have try {} catch {}, it almost FORCES you to use them, all the damn time. For instance:
Java code

class Main
{
public static void main(String args[])
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
input.readLine();
input.close();
System.exit();
}
}

Will not compile. You either have to declare that the method 'main' throws an exception, like:
Java code

class Main
{
public static void main(String args[]) throws IOException
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
input.readLine();
input.close();
System.exit();
}
}

or wrap it in a try {} catch {}. Bloody annoying so it is; sometimes you just want a quick 'n' dirty input.

Admission: sometimes, if a method or code block is small, I will occasionally stick everything on one line, like
Java code

class ObjectWithStringRepresentation
{
...
toString() { return thisClassAsAString; }
}

but I don't do it often.
 
 
 
2010 Apr 26 at 16:34 UTC — Ed. 2010 Apr 26 at 16:37 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
I never really liked Java, or JavaScript.
 
 
 
2010 Apr 26 at 17:39 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
I do use tab, but it wasn't working when I was trying to type it all out earlier (kept tabbing to other items on the page rather than indenting). I'll have a little console game/story done in probably an hour or so, I'll post the source when I get it finished

Also sprinkles, java and javascript are very different, don't hate on javascript cuz you don't like java
 
 
 
2010 Apr 26 at 17:51 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
 
 
 
2010 Apr 26 at 18:30 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
Down Rodeo said:
Actually, I infinitely prefer Java to Javascript. Javascript makes me cry.

I've never worked with java. Javascript is actually pretty easy to work with, in my opinion anyway.
Really my point was though, is they are two completely different languages, so they shouldn't be grouped together.
As far as javascript though, I think in most cases php should take its place. Php is just so much more superior.
Idk why, but the first thing I think of when I think of Java is Runescape, and I hate runescape, so I feel biased against it for that
 
 
 
2010 Apr 26 at 18:46 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Rockbomb said:
Also sprinkles, java and javascript are very different, don't hate on javascript cuz you don't like java


I know, I don't like JavaScript regardless of my relationship with Java.

JavaScript is too dynamic. In JavaScript this can be that and that can be this and a Borfin can be a Throm-dim-bu-lator (more over I cannot tell if a Goor is a Gick, or a Skrux is a Snux or Snoor!).
 
 
 
2010 Apr 26 at 19:05 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
Exactly - its design choices really impact performance. Both Java and JS are object-oriented languages with verbose syntax though! They are slightly similar (obviously excluding the whole compilation thing). I'm at a position where I'm kind of happy with Java. I've been doing proper Javastuff for well over a year now and I'm at the stage where, although we have our differences, some things still piss me off immensely and sometimes it makes me sad, I can live with it. I accept it for what it is and use it accordingly :)
 
 
 
2010 Apr 26 at 19:45 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
I think I will stick with C languages.
 
 
 
2010 Apr 26 at 20:02 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
Well I finished this project, and its available for download... for FREE!
You can download it pre-compiled here, or you can grab the source code and compile it yourself here (not as much fun, as reading through the source will ruin the story).
 
 
 
2010 Apr 26 at 23:07 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
I get the same "side-by-side configuration" message I got before...
 
 
 
2010 Apr 26 at 23:45 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
sprinkles said:
I get the same "side-by-side configuration" message I got before...

Hmmm.... I'll brb, gonna test it on my mom's comp. Should work though, I think its just your comp.

Edit: Well... I got an error on my mom's comp as well. I guess you can just compile the source yourself for now 'til I figure out how to make it work on computers other than mine
 
 
 
2010 Apr 27 at 00:26 UTC — Ed. 2010 Apr 27 at 00:33 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Or look up the message to see why it it happening.
 
 
 
2010 Apr 27 at 00:38 UTC
SuperJer
Websiteman

2005 Mar 21 • 6660
Works here. Nice story, lol.
 
 
 
2010 Apr 27 at 00:38 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Log Name: Application
Source: SideBySide
Date: 4/26/2010 5:46:06 PM
Event ID: 33
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: Sprinkles-Win7
Description:
Activation context generation failed for "C:\Users\Sprinkles\Desktop\noMoreMeth.exe". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="SideBySide" />
<EventID Qualifiers="49409">33</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2010-04-26T23:46:06.000000000Z" />
<EventRecordID>4324</EventRecordID>
<Channel>Application</Channel>
<Computer>Sprinkles-Win7</Computer>
<Security />
</System>
<EventData>
<Data>Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>C:\Users\Sprinkles\Desktop\noMoreMeth.exe</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
</EventData>
</Event>
 
 
 
2010 Apr 27 at 00:42 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
superjer said:
Works here. Nice story, lol.

Heh, this book I'm following said to make a story along the lines of "Your on a magical adventure to save a princess, and on your journey you encounter a cave. A man standing outside the cave says you must pass through three rooms first. This first room is filled with gold, you can take all the gold you want, but it will prove your greed and you lose. The second room is the same with the exception of it being diamonds instead of gold. In the third room there is a dragon attacking a peasent, do you rescue him? If you do you win, if not you lose."

I was like 'ummm, no thanks!' and went off writing my own script
 
 
 
2010 Apr 27 at 00:43 UTC
SuperJer
Websiteman

2005 Mar 21 • 6660
sprinkles said:
Log Name: Application
Source: SideBySide
Date: 4/26/2010 5:46:06 PM
Event ID: 33
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: Sprinkles-Win7
Description:
Activation context generation failed for "C:\Users\Sprinkles\Desktop\noMoreMeth.exe". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
...
...
...

LOL WTF?
What is all that shit?
 
 
 
2010 Apr 27 at 00:47 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Thats the log file windows generates when it fails.
 
 
 
2010 Apr 27 at 00:51 UTC
SuperJer
Websiteman

2005 Mar 21 • 6660
Well that's nice and cryptic. Is that the compile failing or running the program?
 
 
 
2010 Apr 27 at 00:54 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
Hmmm, I wonder... it says "Dependant Assembly" in that log of yours. I wonder if its because of a difference in OS's. Are you running the 32bit version of win7? Cuz I'm running the 64bit.

Thats one thing I was wondering about when I was writing it, is I used the commands 'system("pause");' and 'system("cls");', which I believe will only work on windows, but I didn't even think about different windows platforms...
 
 
 
2010 Apr 27 at 00:55 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
If you are going to keep this up, PLEASE, FOR THE LOVE OF ALL THAT IS HOLY, type either "you are" or "you're" when you mean "you are". I'm not going to put up with "your" any longer, it is hurting my head. AaronJer or Superjer will of course nuke this post but I don't care, you're getting on my tits.

And yes, Visual Studio + errors = XML vomit. Have fun
 
 
 
2010 Apr 27 at 01:05 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
OS doesn't matter. What matters is that I am missing the "Microsoft.VC90.DebugCRT" assembly, which is these DLLs:
msvcr100.dll
msvcp100.dll
msvcm100.dll

superjer said:
running the program



More importantly when I run sxstrace.exe I get an access denied error message (running via command prompt). Why?
 
 
 
2010 Apr 27 at 01:06 UTC — Ed. 2010 Apr 27 at 01:10 UTC
Page [1] 2 3 4