Sunday, July 12, 2009

What is the difference between writing in Visual studio 2005 and writing in visual c++ 6.0?

What is the difference between writing a c++ win32 console application in Visual studio 2005 and writing it in Visual c++ 6.0 ??


because i am having problems while using visual studio 2005 that some functions are not found even after including there headers ..... For example, i can't use rand() and some string functions....


there are also things that i get from the internet that don't work like this function for changing screen color:


void setcolor(unsigned short color) //The function that you'll use to


{ //set the colour


HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);


SetConsoleTextAttribute(hcon,color);


}





errors say that words like HANDLE and hcon are undeclared identifiers .....


Please help!!!

What is the difference between writing in Visual studio 2005 and writing in visual c++ 6.0?
Including the correct headers only gives the compiler the calling sequences for functions. It doesn't give the linker a clue as to where to find those functions to run at execution time.





This is almost certainly a misconfiguration problem while setting up the project. I play with VS 2003 and always have trouble starting new projects, even with some old ones to use as guides. I'd suggest you initialize another project, selecting an Win32 Console Project from the wizard. It may just set up stdafx.h and the preprocessor #defines right for you.





Keep looking at the project's properties for possible problems.





In particular:


C/C++ -%26gt;


Preprocessor-%26gt;Definitions = WIN32;NDEBUG;_CONSOLE


Linker-%26gt;


System-%26gt;Subsystem = Console (/SUBSYSTEM:CONSOLE)





Good luck.
Reply:I am wondering if you're including the correct headers. Those are all defined when you include windows.h.


as far as rand is in math.h which you need to include explicitly, as well.


if you're referring to string function like strcpy etc.


you need to include string.h


No comments:

Post a Comment