Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 07 Jul 2011
Offline Last Active Jul 15 2012 09:12 AM

Topics I've Started

(C++ Beginner) I hate to post here, but... why won't my "if" statement eval...

15 July 2012 - 08:46 AM

I've worked with other languages in the past including basic and a lot of scripting languages, and I have worked a decent bit on C++ too. I haven't worked on C++ in quite a while now, and last night I was trying to refresh myself on the basics... so--and this is a little embarrassing--I wrote this small piece of code for a console program to send my girlfriend:

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
string username = "";

cout << "Hello \n";
cout << "What is your name? ";
getline (cin, username);
cout << "Your name is: " << username;
if (username == "Tiffany" || "tiffany" || "Tiffany McClure" || "tiffany McClure" || "Tiffany Mcclure" || "tiffany mcclue")
  cout << "Your name is Tiffany... \n The Creator has a message for you: \n I love you Cupcake";
  cout << "Your name is not Tiffany.";
return 0;

The problem is... it doesn't appear that the "if (username == "Tiffany" || "tiffany" || "Tiffany McClure" || "tiffany McClure" || "Tiffany Mcclure" || "tiffany mcclue")" statement evaluates correctly, as the program always displays the cout message in the "if" block, even if the if statement should be false.

I know these are beginner C++ concepts that have nothing to do with game development, but... this is like the only forum acct. I have for anything like this, and I hate to create another just to ask this somewhat stupid question.

I appreciate any help with this, I'm trying to pick up C++ again so that maybe I can do something useful with it.

EDIT: Oops. I haven't been on this site in a while. Forgot there was a "For Beginners" Section. This probably belongs there. Sorry about that.

Anyone Here Know Anything About UnrealScript?

12 July 2011 - 12:34 PM

Hello guys.

I've only made a few posts here while I was (well, I'm still in the process of practicing) learning C++.

I have since made the jump to using the Unreal Development Kit for my game projects. So far the Syntax is very similar to C++ which is helpful; however, I'm having a little problem

Note: The reason I havn't posted to the Unreal Forums is that my account is currently not active and i am waiting in a Moderator Queue to allow me onto the forums.

So I was wondering if anyone here knows Unreal Script and would be willing to answer a question I have.

In C++ class functions and members can be accessed by the member operator '.'

This seems to not be the case with unreal script.

I'm trying to figure out how to call class member functions and access class members in Unrealscript for use with my HUD.

Anyone know how accessing other classes works in Unreal Script?

Semantic error with a function. I need some troubleshooting help.

07 July 2011 - 05:52 PM

(NOTE: C++ in Viz C++ Express 2010)

I hate to post again after posting something earlier today. I don't want to burden you guys, or wear out my welcome here.


I have a problem that I have been working on for upwards of 30 Mins now, and I think I really need someone's input besides my own.

so I have this function:

void set_charName()
		using namespace std;
		bool userSatisfied;
		char userInput;
		charName = "";
		cout << "Name your character. Then press 'Enter/Return'. \n";
		getline (cin,charName); //Entering a literal string here with whitespace.   
 			//Then: On loop, the program does not stop here (at 'getline') and allow the user to enter a new line for "charName"
		system ("cls");
		cout << "You have decided to name your character " << charName << ", is this correct?\n   		(Enter Y/N)";
		cin >> userInput;
		if (userInput == 'Y' || userInput == 'y')
			userSatisfied = true;
		else if (userInput == 'N' || userInput == 'n')
			userSatisfied = false;
			cout << "Input not valid";
			userSatisfied = false;

		while (userSatisfied == false);

So, here is the problem:

When I get to this part of the program, and enter a literal string, the function moves on as intended. Which is good; however, whenever I enter an 'n' or 'N' for userInput, the program loops, but does not pause and allow me (the user) to change the value of charName.

C++: Problems with classes. Code Included- Need help.

07 July 2011 - 10:41 AM

So, this is my first post ever on Gamedev.net

I have been working on little game projects since I was like 14, but I never really got serious about it until about 6 months ago. I've been working on C++ over the past couple of weeks, and I need some help. I have been using the guide at www.learncpp.com, and I've been doing fine. However, yesterday I decided it would be a good idea (it wasn't) to speed through 2 chapters to get to OOP (As I've had quite a bit of experience with other languages, and loops/switches/cases/flow control arn't new to me). I got through this fine, but I have this problem. I started OOP and I am trying to practice some OOP skills now. I have the following program and it keeps kicking the same error, no matter how I change it around. Can anyone help?

class Character
	int charstats[5] = {0};

	int statrecieve(int x);
		return charstats[x];

int main()
	using namespace std;

	return 0;

I am using Viz C++ 2010 Express. The compiler keeps giving me the following errors:

1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(16): error C2059: syntax error : '{'
1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(16): error C2334: unexpected token(s) preceding '{'; skipping apparent function body

Can anyone explain why? Any help is appreciated.

PS. I ask why because I am trying to learn. I need to know WHY it is giving me this error so I can avoid it in the future.