8 Replies - 1934 Views - Last Post: 21 November 2012 - 03:49 PM Rate Topic: -----

#1 hack17up  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 19-November 12

Difference between CLRconsole and ConsoleWin32?

Posted 19 November 2012 - 11:34 PM

I am reading a book on C++, just started today.

It described a console application as a non-Windows application. Could someone tell me exactly what they meant by that?

It was brought up because apparently I have to provide the first line: #include "stdafx.h" in console apps.

Not sure if this was important enough to ask about, but I'm just curious.
I don't wanna miss anything since I am self-teaching and lack the teacher to bug about every little thing :P

Also, when I start a project in Visual Studio, it provides me with code similair to the stuff that the book wanted me to type out. The code provided by the book seems much more simple and consolidated, and it worked when running the build. So another part to my hopefully not too vague question... are these differences that don't matter very much?

If I do need to be more informative, please let me know. These were just very general questions needing very general answers.

Thanks~!

Is This A Good Question/Topic? 0
  • +

Replies To: Difference between CLRconsole and ConsoleWin32?

#2 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Difference between CLRconsole and ConsoleWin32?

Posted 19 November 2012 - 11:47 PM

Quote

Difference between CLRconsole and ConsoleWin32?

A CLR (Common Language Runtime) console application uses the .NET framework, whereas a Win32 Console application doesn't.

Quote

It described a console application as a non-Windows application. Could someone tell me exactly what they meant by that?

In Windows you will find that non-windows applications start with the entry symbol "main", but Win32 applications begin with the entry symbol "WinMain". Also, in console applications, a console is obviously opened automatically, although a console can be opened in any application.

Quote

#include "stdafx.h"

stdafx is generally the name given to a precompiled header file.

This post has been edited by Aphex19: 19 November 2012 - 11:49 PM

Was This Post Helpful? 1
  • +
  • -

#3 hack17up  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 19-November 12

Re: Difference between CLRconsole and ConsoleWin32?

Posted 20 November 2012 - 12:48 AM

Thanks! As I read on I was further informed of some of this in my book, so I guess it is just more of that stuff that I won't need to really worry too much about the details of until later.

I hope to follow up with more relevant questions in the future :)

Again, I appreciate the help!
Was This Post Helpful? 0
  • +
  • -

#4 Mrk  Icon User is offline

  • D.I.C Head

Reputation: 29
  • View blog
  • Posts: 66
  • Joined: 03-December 09

Re: Difference between CLRconsole and ConsoleWin32?

Posted 20 November 2012 - 02:25 AM

Quote

It described a console application as a non-Windows application. Could someone tell me exactly what they meant by that?


A Windows application prints output into a window (which is what Windows is all about). So if you are writing a program to work inside of a window, you have to program the design of the window, like what menus it will have at the top (File, Edit, View, etc.,) as well as program it for responses to mouse clicks, etc. In other words, such a program would have to communicate a lot with the Windows operating system. Such a program would be called a Windows application. Windows is a GUI (Graphical User Interface) which relies heavily on mouse input as you know. Making your program run inside of a window is almost a separate programming topic in itself, and requires knowledge of how to use functions and other things. Before you can make your program run inside a window, you have to learn programming first in order to do that. So some other simpler means is needed in order for you to be able to print things out to the screen while you are still learning. That simpler means is called a "console" window. This window cannot use graphics (except a few simple block graphic characters). And there aren't any Windows functions like copy or paste, etc. It's basically just for outputting text to the screen. Once you get some programming under your belt, you can proceed with learning how to make your program operate in a window and use the mouse and make menus and all of that good stuff.

And just so you know, the console on a computer consists of the screen and keyboard (the screen being the console output device and the keyboard being the console input device).

Quote

Difference between CLRconsole and ConsoleWin32?


The Windows operating system has a sub-program that you can add to it (or you most likely already have it installed) which can almost be thought of as a "sub culture". It can run programs that you write for it, and it's called the .Net Framework ("dot Net Framework"). It's much like the Java engine that you need to have installed in order to run programs written in Java. A program written for the .Net Framework (i.e. a CLR program) is only half converted into machine code at the time of compiling, and then the .Net framework program finishes converting the program into machine code "on the fly" when the program is run. This makes program execution a little slower, but it's not too bad for most applications. There are certain advantages to this, but I wouldn't worry about learning it until you have learned quite a bit about C++ first. The CLR part are basically extensions added on to other languages (like C++, Basic, etc) which all get half converted to the same common language to run under the .Net Framework. In any case, just stick with the plain old console programs for now.

Quote

#include "stdafx.h"


When you make changes to your code, you have to then recompile your program. And even if you just make one small change, the WHOLE program has to be recompiled. Even if you have a short program, you still have <iostream> and other header files that can be quite large in size, and can take a little while to recompile every time. To speed up the compiling process, after the first compile those header files are saved in another file so they don't have to keep being recompiled - just the code that you change. That is what stdafx.h is about. When you start a new project, it is automatically set up to use "stdafx.h" to hold the pre-compiled header files. However, you can choose not to use them, because they complicate things when just beginning to learn. After you create a new project, and before clicking on "Finished", look to the left at "Application Settings" and click on that. Then you will see all of the settings for your new project. Just click on "Empty project" and then you will not be using the pre-compiled headers thing and your code will be more basic and less confusing. Later, you can learn about using these pre-compiled headers to speed up the compiling process, and you can read D.I.C's tutorial "Precompiled Headers (fast build)" to learn more about it.
Was This Post Helpful? 2
  • +
  • -

#5 hack17up  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 19-November 12

Re: Difference between CLRconsole and ConsoleWin32?

Posted 21 November 2012 - 12:30 PM

Wow, Mrk. Your post was very helpful! Thanks for breaking it down so nicely for me ^^
Was This Post Helpful? 0
  • +
  • -

#6 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 249
  • View blog
  • Posts: 582
  • Joined: 31-May 11

Re: Difference between CLRconsole and ConsoleWin32?

Posted 21 November 2012 - 01:40 PM

Well, precompiled headers are useful, but it's not always true that in a giant application when you make a single change in one file then everything must be recompiled.
If the change is in a header file that gets included in many different implementation file, then that may be so. However, if the change is in implementation file (.cpp) then usually only this particular file needs to be recompiled.

Just thought I'd point that out. ;)

This post has been edited by Xupicor: 21 November 2012 - 01:41 PM

Was This Post Helpful? 0
  • +
  • -

#7 hack17up  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 19-November 12

Re: Difference between CLRconsole and ConsoleWin32?

Posted 21 November 2012 - 03:06 PM

Thanks! Lots of helpful people on here :)

I thought of another question but just frgot it :(
Was This Post Helpful? 0
  • +
  • -

#8 hack17up  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 19-November 12

Re: Difference between CLRconsole and ConsoleWin32?

Posted 21 November 2012 - 03:35 PM

I just thought of one, though I'm assuming the answer is yes.

Do strings need to be declared? And if so is it just: string string1, string2.. and so on?
Was This Post Helpful? 0
  • +
  • -

#9 hack17up  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 19-November 12

Re: Difference between CLRconsole and ConsoleWin32?

Posted 21 November 2012 - 03:49 PM

I am trying to make a program that asks for your name and then says Hello -name- but it isn't working.

will cin work for strings?
let me shw you my code...

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
	string name
	cout << "Code now, learn later! (lulz?)   ";
	system("PAUSE");
	cout << "What is your name?";
	system("PAUSE");
	cin >> name;
	system("PAUSE");
	cout << "Hello, " << name << "!";
	return 0;
}


I just sort of proof read that code, I guess, so here is the ~new~ code. Same question still stands!

View Posthack17up, on 21 November 2012 - 03:43 PM, said:

I am trying to make a program that asks for your name and then says Hello -name- but it isn't working.

will cin work for strings?
let me shw you my code...

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
	string name
	cout << "Code now, learn later! (lulz?)   ";
	system("PAUSE");
	cout << "What is your name?";
	system("PAUSE");
	cin >> name;
	system("PAUSE");
	cout << "Hello, " << name << "!";
	return 0;
}


Rats... I messed that up. One more time! New code will be below the quote!


View Posthack17up, on 21 November 2012 - 03:46 PM, said:

I am trying to make a program that asks for your name and then says Hello -name- but it isn't working.

will cin work for strings?
let me shw you my code...

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
	string name
	cout << "Code now, learn later! (lulz?)   ";
	system("PAUSE");
	cout << "What is your name?";
	system("PAUSE");
	cin >> name;
	system("PAUSE");
	cout << "Hello, " << name << "!";
	return 0;
}


I just sort of proof read that code, I guess, so here is the ~new~ code. Same question still stands!

View Posthack17up, on 21 November 2012 - 03:43 PM, said:

I am trying to make a program that asks for your name and then says Hello -name- but it isn't working.

will cin work for strings?
let me shw you my code...

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
	string name
	cout << "Code now, learn later! (lulz?)   ";
	system("PAUSE");
	cout << "What is your name?";
	system("PAUSE");
	cin >> name;
	system("PAUSE");
	cout << "Hello, " << name << "!";
	return 0;
}




#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
	string name
	cout << "Code now, learn later! (lulz?)   \n";
	system("PAUSE");
	cout << "What is your name?\n";
	system("PAUSE");
	cin >> name;
	system("PAUSE");
	cout << "Hello, " << name << "!";
	system("PAUSE");
	return 0;
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1