• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Taint

[C++, Linux] Can't compile correct code

9 posts in this topic

I'm using the g++ compiler and it can handle the basic stuff, but as soon as I try to use pointers it gives me errors. I 100% know the code is correct because I even pasted code from C++ Primer 5th Edition into it and it still isn't working. I did download a load of dev libraries when trying to install SFML so I'm thinking maybe that did it, but I don't know. I also don't have the slightest idea how to reverse it.

 

This is the code I pasted from C++ Primer 5th Edition, which apparently is the best book for learning. I've tried compiling it with g++ main.cpp -o main, and also with the -std=C++11 flag.

#include <iostream>
int main()
{
	using namespace std;
	int updates = 6;
// declare a variable
	int * p_updates;
// declare pointer to an int
	p_updates = &updates;
// assign address of int to pointer
// express values two ways
	cout << “Values: updates = “ << updates;
	cout << “, *p_updates = “ << *p_updates << endl;
// express address two ways
	cout << “Addresses: &updates = “ << &updates;
	cout << “, p_updates = “ << p_updates << endl;
// use pointer to change value
	*p_updates = *p_updates + 1;
	cout << “Now updates = “ << updates << endl;
	return 0;
}

Why does this happen every time I try and learn anything new in C++?

0

Share this post


Link to post
Share on other sites

 I 100% know the code is correct

 

Well, i work as a c++ developer, and i am never brave enough to say that when i have a compile error. smile.png

 

At first look it seems fine for me but... please, write the compile error, because it's much more easier to help if we see what's your problem.

Edited by Melkon
1

Share this post


Link to post
Share on other sites

Sorry guys! This is the error:

 g++ main.cpp -o main
main.cpp:12:2: error: stray ‘\342’ in program
  cout << “Values: updates = “ << updates;
  ^
main.cpp:12:2: error: stray ‘\200’ in program
main.cpp:12:2: error: stray ‘\234’ in program
main.cpp:12:2: error: stray ‘\342’ in program
main.cpp:12:2: error: stray ‘\200’ in program
main.cpp:12:2: error: stray ‘\234’ in program
main.cpp:13:2: error: stray ‘\342’ in program
  cout << “, *p_updates = “ << *p_updates << endl;
  ^
main.cpp:13:2: error: stray ‘\200’ in program
main.cpp:13:2: error: stray ‘\234’ in program
main.cpp:13:2: error: stray ‘\342’ in program
main.cpp:13:2: error: stray ‘\200’ in program
main.cpp:13:2: error: stray ‘\234’ in program
main.cpp:15:2: error: stray ‘\342’ in program
  cout << “Addresses: &updates = “ << &updates;
  ^
main.cpp:15:2: error: stray ‘\200’ in program
main.cpp:15:2: error: stray ‘\234’ in program
main.cpp:15:2: error: stray ‘\342’ in program
main.cpp:15:2: error: stray ‘\200’ in program
main.cpp:15:2: error: stray ‘\234’ in program
main.cpp:16:2: error: stray ‘\342’ in program
  cout << “, p_updates = “ << p_updates << endl;
  ^
main.cpp:16:2: error: stray ‘\200’ in program
main.cpp:16:2: error: stray ‘\234’ in program
main.cpp:16:2: error: stray ‘\342’ in program
main.cpp:16:2: error: stray ‘\200’ in program
main.cpp:16:2: error: stray ‘\234’ in program
main.cpp:19:2: error: stray ‘\342’ in program
  cout << “Now updates = “ << updates << endl;
  ^
main.cpp:19:2: error: stray ‘\200’ in program
main.cpp:19:2: error: stray ‘\234’ in program
main.cpp:19:2: error: stray ‘\342’ in program
main.cpp:19:2: error: stray ‘\200’ in program
main.cpp:19:2: error: stray ‘\234’ in program
main.cpp: In function ‘int main()’:
main.cpp:12:19: error: found ‘:’ in nested-name-specifier, expected ‘::’
  cout << “Values: updates = “ << updates;
                   ^
main.cpp:12:13: error: ‘Values’ has not been declared
  cout << “Values: updates = “ << updates;
             ^
main.cpp:12:35: error: expected primary-expression before ‘<<’ token
  cout << “Values: updates = “ << updates;
                                   ^
main.cpp:13:13: error: expected primary-expression before ‘,’ token
  cout << “, *p_updates = “ << *p_updates << endl;
             ^
main.cpp:13:32: error: expected primary-expression before ‘<<’ token
  cout << “, *p_updates = “ << *p_updates << endl;
                                ^
main.cpp:15:13: error: ‘Addresses’ was not declared in this scope
  cout << “Addresses: &updates = “ << &updates;
             ^
main.cpp:15:22: error: expected ‘;’ before ‘:’ token
  cout << “Addresses: &updates = “ << &updates;
                      ^
main.cpp:16:13: error: expected primary-expression before ‘,’ token
  cout << “, p_updates = “ << p_updates << endl;
             ^
main.cpp:16:31: error: expected primary-expression before ‘<<’ token
  cout << “, p_updates = “ << p_updates << endl;
                               ^
main.cpp:19:13: error: ‘Now’ was not declared in this scope
  cout << “Now updates = “ << updates << endl;
             ^
main.cpp:19:17: error: expected ‘;’ before ‘updates’
  cout << “Now updates = “ << updates << endl;

1

Share this post


Link to post
Share on other sites

A colleague was recently befuddled why a simple command line argument wasn't working.  He was passing in -n as an argument, copied straight from an email.

 

Well, it turned out, some email editor (Outlook) had changed the "-" to some longer single character - (possibly UNICODE) and it was screwing up the argument.

 

Lesson is, be careful when copying and pasting;  sometimes it doesn't give you exactly what you expect.

1

Share this post


Link to post
Share on other sites

A colleague was recently befuddled why a simple command line argument wasn't working.  He was passing in -n as an argument, copied straight from an email.

 

Well, it turned out, some email editor (Outlook) had changed the "-" to some longer single character - (possibly UNICODE) and it was screwing up the argument.

 

Lesson is, be careful when copying and pasting;  sometimes it doesn't give you exactly what you expect.

 

 

I had a similar experience in my ancient history, pasting code from word.  MIcrosoft apparently have a "smart quote" character, and non-Visual Studio compilers really weren't happy with it.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0