Thread: In the beginning...

  1. #16
    Unregistered
    Guest

    Smile

    O.K. thanks a lot for all of the informitive replies I really appreciate it but now I have a few more subject related questions.

    1] I have that "MicroSoft's Introductory Visual C++ Compiler". I haven't tried yet but I am assuming I can type C code into that and it will work just fine...please tell me if I am wrong.

    2] Can anyone reccomend any books for me. I am looking at maybe getting "Sam's Teach Yourself C Programming in 21 Days"(hence the previous questions about if I need to know C or if it is useful to know C because there is also "Sam's Teach Yourself C++ Programming in 21 Days" and I didn't want to buy the first book and then find out I could have gotten the second one and been just fine which brings me back to if I learn C++ does that mean I will be able to write C or just be able to understand it?). Also is it a good idea for me to buy both and learn them one after another so that I have a good base of C programming and then be able to easily learn the few new functions and structs or whatever they are in C++.

    3] Also I don't know how old all of you are but (and this may seem like a strange request) would anyone who sees this post cosider teaching me, even just the basics so I can get a good foothold before trying to learn on my own.

    Thanks again
    Chris

  2. #17
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    The introductory (which I also have) can be a pain if you use certain libraries like Allegro

  3. #18
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Alright, here is an example that will prove I am correct. I'm not trying to sound like an a$$ here but simply trying to prove a point. Try the following code in a C++ compiler and get the error, then try it on a C compiler and you will not.

    Code:
    #include <stdio.h>
    
    int main( void )
    {
    	void *foo = NULL;
    	char *ch = NULL;
    
    	ch = foo;
    
    	return 0;
    }

  4. #19
    Registered User
    Join Date
    May 2002
    Posts
    317
    void is a valid type for a pointer? How exactly is this?

  5. #20
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Traveller
    void is a valid type for a pointer? How exactly is this?
    C++ will give you an error without using a cast like my code. C this is very common and does not require the cast. Merely stating that some C code will NOT compile on a C++ compiler.

    EDIT: I re-read your question and I see what you are asking now. You wonder what a void * is? It is simply a pointer to some memory location and the type does not matter. It's basically just a generic pointer. Did I read the question wrong? Sorry.
    Last edited by MrWizard; 05-29-2002 at 01:34 PM.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  6. #21
    Registered User
    Join Date
    May 2002
    Posts
    317
    Hey, no problem. Thanx, that's what I was wondering about. So you could generate a few void pointers and assign them types and values later, however C++ requires an explicit type cast. Do I have the idea straight?

  7. #22
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Traveller
    Hey, no problem. Thanx, that's what I was wondering about. So you could generate a few void pointers and assign them types and values later, however C++ requires an explicit type cast. Do I have the idea straight?
    Exactly.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2008, 07:54 PM
  2. Replies: 15
    Last Post: 05-13-2006, 09:28 PM
  3. writing to the beginning of a file
    By cloudy in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2006, 01:47 PM
  4. writing to the beginning of the file
    By Jules in forum C++ Programming
    Replies: 1
    Last Post: 05-19-2004, 01:31 AM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM