|
<small><b>Raistlfiren wrote:</b></small>
<i>So wait wouldn't this be right though: #include ?</i>
If you check 'Do not treat <'s as HTML tags', then I can see your includes. I've looked at the page source, and you're asking if #include <iostream.h> is right. No, it's not. The header is there, and will work, but it's not valid C++, it predates the C++ standard. If your book says to use it, burn the book and buy a decent one. You should #include <iostream>, which means you need to put using std::cout;, etc. as it places those things in namespace std.
Raistlfiren wrote:
So string classes are all of the classes that define words like if I were to say "cout << big" it would then say dog in the displayed text? Those are string classes?
YEs, as someone else explained, if you #include <string>, then you can do this
string big = "dog";
cout << big;
A string class gives you a lot more than a container, you can search in the string, and do operations on it, and it handles the memory allocations for you.
Raistlfiren wrote:
Then, the file you type in command prompt is what the arguements define?
What do you mean ?
Raistlfiren wrote:
So where is this standard library at that defines namespace std?
It's in a subdirectory of your compiler, and your compiler is set up to look there for files, that's what the #include <> means, to look in library directories, #include "string" would look in the local directory first.
Raistlfiren wrote:
Then use std::string to define a library that is in the namespace library?
using std::string tells the compiler that when you type string in the global namespace, to use the one in std. You also need to #include it, so it knows about it.
Raistlfiren wrote:
I am kind of just trying out a whole bunch of programming languages
I'd suggest you don't. Stick with one, until you know it. And don't worry that you don't know it all, start in a corner and learn one bit, then move on from there. Write some simple programs ( for example, I wrote a command line calculator early on ), and treat them as exercises that will expand your knowledge.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the great information!
Christian Graus wrote:
Raistlfiren wrote:
Then, the file you type in command prompt is what the arguements define?
What do you mean ?
If I only knew what I mean! I think you guys have answered a lot of my questions already, and I will check out those tutorials that you have sent me. The only problem is that I want ot know a lot of each language and in a short period of time. I have different reasons to learn each programming language... Anyway, like I said your help was muchly appreciated!
Thanks,
Raistlin
|
|
|
|
|
Raistlfiren wrote:
Thanks for the great information!
Happy to help
Raistlfiren wrote:
The only problem is that I want ot know a lot of each language and in a short period of time.
You're better off looking for deep understanding than broad. Understand the thing you're looking at for now really well, instead of trying to have a bit of an understanding over a broad range in the short term.
Good luck !!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'll second the opinion that you're trying to do too much at once, a classic formula for frustration and confusion. I believe a good approach for you would be to pick a language -- interpreted languages like Python are better for learning than C++, IMHO -- find a good book on learning to program using that language, and have fun. Note that a book on learning Python, and a book on learning programming using Python are two different things, and you want the latter. How to Think Like a Computer Scientist[^] might be a good place to start. Also note that Google, and the internet in general, can be your enemy in this endeavor as well as your friend; there's a tremendous amount of information out there, and Sturgeon's Law ("90% of everything is crap") definitely applies. The folks here on CP are a tremendous source of knowledge, and are always helpful when you really get stuck. Just make the effort to find the answers yourself first -- you'll learn more that way. Oh, and whatever you do, don't post programming questions in the Lounge. That way lies madness...
|
|
|
|
|
I usually do find most of my information, though the questions here I displayed I have not been able to find or I haven't understood it should be better to say... Yeah I am probably the person who find the 90% of crap and I never find the 10% of good stuff..I have learned hard lesson of not posting in the Lounge computer programming questions. lol
-Raistlin
|
|
|
|
|
Raistlfiren wrote:
Yeah I am probably the person who find the 90% of crap and I never find the 10% of good stuff
But you DID find CodeProject
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
LoL.. This is one of the only 10% site site.
Raistlin
|
|
|
|
|
Hi All,
I am a newbie to visual C++ and .NET. I am working on a project which involves Visual C++ , MFC. I have an application and when I compile and run it I get a bunch of:
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MpApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c019.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c019.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c019.
I have no idea why this happens and do not know how to go about debugging this. Also after showing all this exception my application runs fine. I made changes to the Debugger to break into the code on the exception and the first exception occurs in a windows file oleinit.cpp at the line:
SCODE sc = ::OleInitialize(NULL);
Please give me some guidance/pointers of what to do.
Thanks to All
|
|
|
|
|
The short answer: Never mind first-chance exceptions. They are not bugs. They are just what it says: a first chance to handle an exception. They will be send to you to give you an opportunity to handle the exception before the framework gets to it, but I have never seen a case where I needed to deal with a first-chance exception. They will usually be handled quite sufficiently by the framework.
The exceptions you get are probably due to memory being allocated but not committed, or memory not being allocated yet. My guess is that OleInitialize uses these exceptions in its memory allocation scheme and that they are part of normal execution.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi all,
I have a linked list of
typedef struct someStruct{
DatasourasRex someData;
someStruct *nextElement;
}someStruct;
so I have a list where 1 of these points to the second and a second points to the 3rd. I wish to remove the second so I have just set the pointer to point to the 3rd. But Id imagine this would give me problems with memory leaks maybe? I have used malloc each time to give me the memory, so how do I deallocate?
Thanks in advance
|
|
|
|
|
Use free
There's a link to an example at the bottom of the page.
In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock!
-- Harry Lime
|
|
|
|
|
NEVER use free unless you use malloc and NEVER use malloc if you're using C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Why? I always automatically use 'new' and 'delete' in C++, but i'm just curious what your 'motivations' are for not using 'malloc' and 'free' in C++.
Er zit een korstje op mijn aars.
|
|
|
|
|
new and delete use constructors/destructors and let you make full use of OO, malloc and free only control memory.
Elaine
The tigress is here
|
|
|
|
|
If you are using objects, which have constructors and destructors, malloc() and free() will not work. The new and delete operators will, however. Allocating room for other types such as int , char , and double will work just fine with malloc() and free() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
1. NEVER use free or malloc in C++
2. Never write your own linked list class for production, use std::list.
3. It's good to write one though, to learn. If you want to remove an item from the list, you delete the someStruct in question, and you take the item that is before it, and change it's nextElement pointer to the item after it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
1. NEVER use free or malloc in C++
Unless you're overloading operator new
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi might be doing his college project rite, so using list and other std templates would defeat the perpose of using the list.
-prakash
|
|
|
|
|
Mr.Prakash wrote:
Hi might be doing his college project
Yes, that's why I said, it's a good idea to write these things to learn, but once he enters the real world, he shouldn't be using his own list class.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can someone update the data in a modeless window?
I write this to show the dialog..
Class *dlg=new Class;
dlg->Create(IDD_INFO_DIALOG);
dlg->ShowWindow(SW_SHOW);
and to update something I write:
dlg->m_data=newdata;
but it doesn't update the data..
How can I update them.. UpdateData doesn't work also..
thanks..
|
|
|
|
|
You shouldn't expose data in a dialog, you should expose methods that take the data, and also call UpdateData or Invalidate to cause it to be painted.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The code goes like this:
<br />
ImInfo *info;<br />
info=new ImInfo;<br />
info->Create(IDD_INFO_DIALOG);<br />
info->ShowWindow(SW_SHOW);<br />
UpdateInfo();<br />
<br />
where:<br />
void UpdateInfo()<br />
{<br />
....calcylating the data...<br />
<br />
bool ret=info->transfer(file,width,numy,size,bpp,ctype);<br />
if (!ret)<br />
AfxMessageBox("Cannot transfer data");<br />
}<br />
<br />
and:<br />
bool ImInfo::transfer(CString imagefile, int width, int height, int size, int bpp, CString ctype)<br />
{<br />
m_filename=imagefile;<br />
m_xres=width;<br />
m_yres=height;<br />
m_filesize=size;<br />
m_bpp=bpp;<br />
m_ctype=ctype;<br />
UpdateData(FALSE);<br />
<br />
return TRUE;<br />
}<br />
Is there any mistake here? It doesn't work
|
|
|
|
|
bool and BOOL are not the same thing. Also, why have a function returning bool, if it never checks anything ?
But apart from that, I don't see why this would not work. Try adding a call to Invalidate(); before you return true ( not TRUE ), and if that does not work, then I don't know.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It worked.. I wanted to return something to see if it's the function's problem..
Thanks anyway!
|
|
|
|
|
I am trying to learn C++ .net. I have done a little with VBA and VB.net.
I bought Visual C++ .net for Dummies. I was trying one of the programs in the book. I using Visual Studio .net 2003.
The example in the book is an example of an unmanaged C++ program.
So I created a Win32 Project. I also tried creating a Win32 Console Project and a C/C++ Console Application. Below is the code I typed in. This is the code from the Dummy book. And I am getting a Build error. And I also tried to build the project that is on the actual CD from the dummy book.
//HelloWorld2
// Prints hello world on the screen
//Unmanaged
#include "stdafx.h"
#include <iostream.h>
int _tmain(int argc, _TCHAR* argv[])
{
//Write to the screen
cout << "Hello World\n";
return 0;
}
Here is the error I am getting:
fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
c:\Documents and Settings\steve\Desktop\Code\HelloWorld2\HelloWorld2.cpp(6):
I reinstalled Visual Studio but I guess that was not the problem. I also searched my computer for iostream.h. It did not find the file. I went to the folder vc7 and then the include folder. I found iostream but it was not iostream.h.
Does anyone have any suggestions. Is there a difference in using Visual C++ .net and C++ .net in Visual Studio?
Thanks for any help.
Steve
|
|
|
|