Sign in to follow this  
bionic_atom

I switched to VC++ but im confused now.

Recommended Posts

OK, I currently just switched to Visual C++ latest 05 Express edition, for I was getting tired of the SDL not working with codeblock or whatever the heck I was using, and was told VC++ is so much easier. What a load of crap. I had to reconfigure the App.htm, corewin_express.vsprops file not to mention the directories just to start building a window application after spending 5 hours + on a BellSouth DSL line downloading and installing the VC++ and Platform SDK to come to realize that all the C++ I have learned in the past 2 weeks doesn't even work in it. How come? If it's C++ like it says on it's fancy microsoft logo, title, window, etc... it should use the C++ language but i go and use cout<< and do the using name space std; and some other stuff to start building some small stuff to see if it works, and it doesn't recognize any of it. how come? I wanted to be a game developer and still do, but im just frustrated with learning all these different languages if they are suppose to be the same. I looked up with reference in a console window I use printf("statement string"); but how do I pause it? it's certainly not System("PAUSE"); or System.pause; I tried all different combos but wasn't satisfied. Well im going to bed now, but just curious since Im going to have to learn C++ for being a game developer and the most of em use this V C++ how can I learn this language? I honestly thought I have already learned it with Dev C++, and Codeblocks, and my books I have but no code I had would work. Please direct me in the right path. And as always I appreciate the readers who actually finish my frustrated messages. Until then... Take Care! c.s. finch

Share this post


Link to post
Share on other sites
Quote:
Original post by bionic_atom
I had to reconfigure the App.htm, corewin_express.vsprops file not to mention the directories just to start building a window application after spending 5 hours + on a BellSouth DSL line downloading and installing the VC++ and Platform SDK to come to realize that all the C++ I have learned in the past 2 weeks doesn't even work in it.

Had to reconfigure? I've never even heard of those files. What do you mean you had to reconfigure them and what lead you to believe this?

What was the exact code you tried to compile and what were the errors it gave you?

Share this post


Link to post
Share on other sites
Quote:
Original post by Colin Jeanne
Quote:
Original post by bionic_atom
I had to reconfigure the App.htm, corewin_express.vsprops file not to mention the directories just to start building a window application after spending 5 hours + on a BellSouth DSL line downloading and installing the VC++ and Platform SDK to come to realize that all the C++ I have learned in the past 2 weeks doesn't even work in it.

Had to reconfigure? I've never even heard of those files. What do you mean you had to reconfigure them and what lead you to believe this?

What was the exact code you tried to compile and what were the errors it gave you?


Sorry, I probably should of explained a little more. http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ is where I got the link and it's where I downloaded the stuff. It said and I quote "In order to use Visual C++ Express to build Win32 applications, you'll need to take just a few more steps" Please forgive me but a few steps my ass for Win32 Apps. But i actually figured all that out OK, but im still frustrated much with the whole language linguistik? C++ definition it has. I can't use the code i've been learning in C++ for the past 2 weeks in a console app how come? for instance I tried

#include <iostream>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

const int SIZE = 100;

struct inv_type {
char item[40];
double cost;
double retail;
int on_hand;
int lead_time;
} invtry[SIZE];

void enter(), init_list(), display();
void update(), input(int i);
int menu();
using namespace std;


struct
{
char item[40]; //name of item
double cost; //cost
double retail; //retail price
int on_hand; //amount on hand
int lead_time; //number of days before resupply
}temp;


int main()
{
char choice;

init_list();

for(;;)
{
choice = menu();
switch(choice)
{
case 'e': enter();
break;
case 'd': display();
break;
case 'u': update();
break;
case 'g': return 0;
}
}
}

//Initialize the inv_type_info array.
void init_list()
{
int t;

for(t=0; t<SIZE; t++) *invtry[t].item = '\0';
}

//Get a menu selection
int menu()
{
char ch;
init_list();

cout << "\n";
do
{
cout<<"(E)nter\n";
cout<<"(D)isplay\n";
cout<<"(U)pdate\n";
cout<<"(Q)uit\n\n";
cout<<"Choose one: ";
cin >> ch;
}while(!strchr("eduq", tolower(ch)));
return tolower(ch);
}

//Enter items into the list
void enter()
{
int i;
for(i=0; i<SIZE; i++)
if(!*invtry[i].item) break;

if(i==SIZE)
{
cout <<"List full\n";
return;
}
input(i);
}

void input(int i)
{
char str[80];
cout<<"Item: ";
cin >> invtry[i].item;

cout<<"Cost: ";
cin>>invtry[i].cost;

cout<<"Retail Price: ";
cin>>invtry[i].retail;

cout<<"On hand: ";
cin>>invtry[i].on_hand;

cout<<"Lead time to resupply (in days): ";
cin>>invtry[i].lead_time;
}

//Modify an existing item.
void update()
{
int i;
char name[80];

cout<<"Enter item: ";
cin>>name;

for(i=0; i<SIZE; i++)
if(!strcmp(name, invtry[i].item)) break;

if(i==SIZE){
cout<<"Item not found\n";
return;
}

cout<<"Enter new information.\n";
input(i);
}

//Display the list.
void display()
{
int t;
for(t=0; t<SIZE; t++){
if(*invtry[t].item){
cout<<invtry[t].item<< "\n";
cout<<"Cost: "<<invtry[t].cost;
cout<<"\nRetail: ";
cout<<invtry[t].retail<<"\n";
cout<<"On hands: "<<invtry[t].on_hand;
cout<<"\nResupply time: ";
cout<<invtry[t].lead_time<<" days\n\n";
}
}
}


which is a very simple program that I made in Dev C++ and later threw in Codeblocks since I switched editors but it worked fine in both C++ editors, but when I threw it in Visual C++ it didn't. So, I started simpler I did a simple Hello world console base stuff. But it still said it had building errors. Why is this?

Share this post


Link to post
Share on other sites
The sample program you posted compiled and ran for me using Visual C++ Express. (I tried it as a "Win32 Console Application" with precompiled headers disabled.)

Could you list some of the errors you were getting when you tried it?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by bionic_atom
OK, I currently just switched to Visual C++ latest 05 Express edition, for I was getting tired of the SDL not working with codeblock or whatever the heck I was using, and was told VC++ is so much easier. What a load of crap. I had to reconfigure the App.htm, corewin_express.vsprops file not to mention the directories just to start building a window application


I admit this is a minor annoyance, but look on the bright side - now that you've configured it once you won't have to do it again.

[quote]Original post by bionic_atom
all the C++ I have learned in the past 2 weeks doesn't even work in it. How come? If it's C++ like it says on it's fancy microsoft logo, title, window, etc... it should use the C++ language but i go and use cout<

Share this post


Link to post
Share on other sites
To make a simple console application you don't need to hand edit those files. Also, when creating your project did you choose Win32->Console Application? If you choose CLR Console Applications, there will be problems, and it is an easy mistake to make. Also when making a simple project, I would go into the Application Settings options (while creating the project) and check "Empty project."

Share this post


Link to post
Share on other sites
Thanks for the advice. Problem was in the project options precompiled headers. Now I just need to figure out how to do a system pause thing. thanks for the help.

Share this post


Link to post
Share on other sites
If you mean this...

system("PAUSE");

It works, but it's not the best option. I'll let someone else tell the best because i honestly don't know it. And it also depends on the context in which you need the pause.

btw. If the pause is just so you can debug and view output at the end of your program execution, visual studio automatically adds it in if you run the program in debug mode.

Share this post


Link to post
Share on other sites
You not really learning a new language just an IDE which is the Development environment (simplly put the app yo are working with). After you get use to every thing trust me you would be loving it. It is packed with extra feature not present in other IDE like code block. Just look at the samples from microsoft and everything should be okay.


[edit]

yeah it really blows that you have to download the psdk just for win32 development they should have something lite to download since some might not need all of it PLUS having the broken MFC really made me mad beacuase I see it there and thought i could learn it too but low and behold it doesn't work. bummer but over all its still worth the update

Share this post


Link to post
Share on other sites
To stop the window from closing at the end of the program, either:
  • Start without debugging (Ctrl+F5), or;
  • Set a breakpoint on the closing brace of the program.

Share this post


Link to post
Share on other sites
Quote:
Original post by bionic_atom
...come to realize that all the C++ I have learned in the past 2 weeks doesn't even work in it.

I don't know where you're learning your C++, but please stop. Find a different tutorial/book/whatever. Your current C++ source appears completely and utterly useless. It's not teaching you C++. It's teaching you a revolting over-complicated, under-powered mixture of C and C++ that some of us like to call "C with Classes". Real C++ would look more like:
// <string.h> and <ctype.h> are deprecated in C++
// and replaced by <cctype> and <cstring>
#include <cctype>
#include <cstring>
#include <iostream>
// <string> contains the C++ textual data type std::string
#include <string>
// <vector> contains the C++ dynamic array class std::vector
#include <vector>

const int SIZE = 100;

struct inv_type
{
// use a std::string, not a char[n] for text
// eliminates buffer-overflow exploits,
// too-small arrays and a whole host of
// other problems
std::string item;
double cost;
double retail;
int on_hand;
int lead_time;
};

// a dynamic array of inv_type objects
// you can add as many objects as you like
// (up to available memory) and the vector
// will resize itself to accomodate them
std::vector< inv_type > inventory;

void enter();
void display();
void update();

// this prototype has changed to accept an
// inv_type object by reference
// passing by reference means we operate
// directly on the thing that was passed,
// not a copy
void input(inv_type & item);
int menu();

using namespace std;

int main()
{
char choice;
for(;;)
{
choice = menu();
switch(choice)
{
case 'e': enter();
break;
case 'd': display();
break;
case 'u': update();
break;
case 'q': return 0;
}
}
}

//Get a menu selection
int menu()
{
char ch;

cout << "\n";
do
{
cout<<"(E)nter\n";
cout<<"(D)isplay\n";
cout<<"(U)pdate\n";
cout<<"(Q)uit\n\n";
cout<<"Choose one: ";
cin >> ch;
} while (!strchr("eduq", tolower(ch)));
return tolower(ch);
}

//Enter items into the list
void enter()
{
// this is no longer necessary, since
// the vector can grow beyond SIZE
// I left it in to keep the examples
// equivalent
if (inventory.size() == SIZE)
{
cout <<"List full\n";
return;
}

// create an inv_type object, fill it
// and add it to the vector
inv_type item;
input(item);
inventory.push_back(item);
}

void input(inv_type & item)
{
// read data into the inv_type
// object we were given

cout << "Item: ";
cin >> item.item;

cout << "Cost: ";
cin >> item.cost;

cout << "Retail Price: ";
cin >> item.retail;

cout << "On hand: ";
cin >> item.on_hand;

cout << "Lead time to resupply (in days): ";
cin >> item.lead_time;
}

//Modify an existing item.
void update()
{
// again, std::string for text, not char[n]
string name;

cout << "Enter item: ";
cin >> name;

for (size_t i = 0; i < inventory.size(); ++i)
{
if (inventory[i].item == name)
{
// pass the array entry to the
// input function to allow the
// function to modify it
// remember we're passing by
// reference
input(inventory[i]);
return;
}
}

cout << "Item not found\n";
}

//Display the list.
void display()
{
// The vector doesn't have invalid
// entries, so we don't have to
// test before printing
for (size_t t = 0; t < inventory.size(); ++t)
{
cout << inventory[t].item << "\n";
cout << "Cost: " << inventory[t].cost;
cout << "\nRetail: ";
cout << inventory[t].retail << "\n";
cout << "On hands: " << inventory[t].on_hand;
cout << "\nResupply time: ";
cout << inventory[t].lead_time << " days\n\n";
}
}

That's still far from perfect. I've tried to keep it as close to your version and as simple as possible and haven't addressed any of the design or naming issues. This is just meant as an example of what a good C++ tutorial should be teaching you. Keep searching until you find one that helps you make sense of this. You'll be doing yourself a favour.

Σnigma

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Enigma
Quote:
Original post by bionic_atom
...come to realize that all the C++ I have learned in the past 2 weeks doesn't even work in it.

I don't know where you're learning your C++, but please stop. Find a different tutorial/book/whatever. Your current C++ source appears completely and utterly useless. It's not teaching you C++. It's teaching you a revolting over-complicated, under-powered mixture of C and C++ that some of us like to call "C with Classes". Real C++ would look more like:
*** Source Snippet Removed ***
That's still far from perfect. I've tried to keep it as close to your version and as simple as possible and haven't addressed any of the design or naming issues. This is just meant as an example of what a good C++ tutorial should be teaching you. Keep searching until you find one that helps you make sense of this. You'll be doing yourself a favour.

Σnigma


I appreciate the direct truthful criticism. Im trying for a major in comp sci, but right now my college this semester, nor the next isn't offering in C++ classes. But, I have $50. Do you recommend a good book for me?

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