how to start with Visual Studio C++ Express

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

h4ever

Member
Aug 30, 2013
163
0
0
Does it mind of we type the asterix as so:

Code:
 int _tmain(int argc, TCHAR *argv[]) {}
or as so
Code:
 int * i;
or as so:
Code:
 int* i;
or as so
Code:
 int *i;
?

In tutorial on cplusplus I have seen mixing these two
Code:
 int * i;
int* i;
looks both refer to dereference operator.
however TCHAR *argv[] seems to mean something different.
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
Does it mind of we type the asterix as so:

Code:
 int _tmain(int argc, TCHAR *argv[]) {}
or as so
Code:
 int * i;
or as so:
Code:
 int* i;
or as so
Code:
 int *i;
?

In tutorial on cplusplus I have seen mixing these two
Code:
 int * i;
int* i;
looks both refer to dereference operator.
however TCHAR *argv[] seems to mean something different.

I prefer int* i, it is easy do understand that i is a pointer to Integer.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I prefer int* i, it is easy do understand that i is a pointer to Integer.

One of the oldest arguments in the C++ community, and probably still not settled :).

My preference was always...

int *i

Because this, if I recall correctly, is legal...

int i, j, *k

Although arguably not a good practice.
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
One of the oldest arguments in the C++ community, and probably still not settled :).

My preference was always...

int *i

Because this, if I recall correctly, is legal...

int i, j, *k

Although arguably not a good practice.

Haha yes, at work we debated a long time on this before finalizing with Int* :)
 

h4ever

Member
Aug 30, 2013
163
0
0
Well, now I read on msdn about pointers, references and handlers! Yes, I have found these one are not the same. So I paste it here, just for me to remember.

^ provides a handle through which the garbage collector can track a reference to an object on the managed heap...

Because native C++ pointers (*) and references (&) cannot be tracked precisely, a handle-to object declarator is used.

However, what is the gain or advantage when I use Managed objects instead of Native objects? Is it because it is simpler to work with them? When you allocate memory to Managed objects you dont need to take care about deleting them when you finished. But there should be some more benefit, I'm convinced. What is it? When is it necessary to use it?
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
Well, now I read on msdn about pointers, references and handlers! Yes, I have found these one are not the same. So I paste it here, just for me to remember.

^ provides a handle through which the garbage collector can track a reference to an object on the managed heap...

Because native C++ pointers (*) and references (&) cannot be tracked precisely, a handle-to object declarator is used.

However, what is the gain or advantage when I use Managed objects instead of Native objects? Is it because it is simpler to work with them? When you allocate memory to Managed objects you dont need to take care about deleting them when you finished. But there should be some more benefit, I'm convinced. What is it? When is it necessary to use it?

1.The OS does the garbage collection for you.

2.Though automatic garbage collection is useful it comes with performance penalties(it is getting better but not quite there yet). The rule of thumb regarding memory allocation is you should be able to De-allocate it in the same function, otherwise we will be left with dangling pointers.
 

h4ever

Member
Aug 30, 2013
163
0
0
What does mean the <byte> one the line bellow?

Code:
 array<Byte>^rgbValues = gcnew array<Byte>(bytes);

does it specify type for the array elements?
 

h4ever

Member
Aug 30, 2013
163
0
0
It is from MSDN example of locking bitmap
I would like understand this:

http://paste.ofcode.org/ntpebmjHEBYWdvzeX4H25p
line 39-40

Code:
for ( int counter = 8; counter < rgbValues->Length; counter += 9 )
   rgbValues[ counter ] = 255;
1. how can I check what value is rgbValues->Length

coz as I understand it I have win32 window opened so I need probably another window to create console? How would you do it?

2. it seems to me strange why the
rgbValues[integer] = value ... value is not in not in RGB. How is it possible they work with this simple number to set color? So if I would like to set it to different color like hex=022DDF what to do?

3. I have a image with black rectangle, but I see white lines... that is probably ok until the lines crosses the black line of rectangle. In the place where it corosses it has green or red pixels... Why? Or how to do it if I would want to see same color there like the rectangle.

Just want to understand it how it works.

4. Why the image is so little. The original image is 800*600 pixels and the rectangle is in the upper left corner. But the result is small window with the rectangle only. Like it has been resized or what.

I have uploaded the image here:
http://oi39.tinypic.com/2m5b0ae.jpg
 
Last edited:

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
It is from MSDN example of locking bitmap
I would like understand this:

http://paste.ofcode.org/ntpebmjHEBYWdvzeX4H25p
line 39-40

Code:
for ( int counter = 8; counter < rgbValues->Length; counter += 9 )
   rgbValues[ counter ] = 255;
1. how can I check what value is rgbValues->Length
Put a breakpoint on that line of code

coz as I understand it I have win32 window opened so I need probably another window to create console? How would you do it?
When you run using the debugger, if there is a console window needed for the application, it will create it for you

2. it seems to me strange why the
rgbValues[integer] = value ... value is not in not in RGB. How is it possible they work with this simple number to set color? So if I would like to set it to different color like hex=022DDF what to do?

3. I have a image with black rectangle, but I see white lines... that is probably ok until the lines crosses the black line of rectangle. In the place where it corosses it has green or red pixels... Why? Or how to do it if I would want to see same color there like the rectangle.

Just want to understand it how it works.

4. Why the image is so little. The original image is 800*600 pixels and the rectangle is in the upper left corner. But the result is small window with the rectangle only. Like it has been resized or what.

I have uploaded the image here:
http://oi39.tinypic.com/2m5b0ae.jpg

Gave you a couple of hints; have fun :p
 

h4ever

Member
Aug 30, 2013
163
0
0
Well, thanks. Length is almost 2 million. However 800x600 should be 480000... This is image size. But if it is lengh of pctBox->Size, ok that make sense. However how would you do it to have pctBox->Size same size as the image. I see the problem here because pctBox->Image was not defined yet.
 

h4ever

Member
Aug 30, 2013
163
0
0
I see that the pointers should be correctly written as Type *PointerName because in the cpusplus tutorial about pointers I read:

Using a pointer we can directly access the value stored in the variable which it points to. To do this, we simply have to precede the pointer's identifier with an asterisk (*), which acts as dereference operator and that can be literally translated to "value pointed by".

Therefore, following with the values of the previous example, if we write:
beth = *ted;
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
I see that the pointers should be correctly written as Type *PointerName because in the cpusplus tutorial about pointers I read:

Both are correct, it comes down to personal preference really.
 

h4ever

Member
Aug 30, 2013
163
0
0
Could you help me to open project in Visual Studio. I have downloaded open source program from here, which I wanted to start. But I have some mistakes there, so want to ask you what I must to to make it working/success debugin in Visual Studio.

The source project is save here:
http://sourceforge.net/projects/aokts/postdownload?source=dlp
It is program to edit scenario for game AOK.

So when I open aokts.log I see this messages:

http://paste.ofcode.org/3ba4UDw8UpjR8QvkMHmjpX6

I got message that there is missing aokts.exe which is silly, because the aokts.exe is the program which should be built. Also I see there are missing some files like
zlib.h
but this one was not even in the old versions but there is some zlib1.dll and libexpatw.dll so I don't know how to make this working.

I actually want to try to get some class from the source code, if I could be able to decode the scenario file to get object/units into array.
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
Could you help me to open project in Visual Studio. I have downloaded open source program from here, which I wanted to start. But I have some mistakes there, so want to ask you what I must to to make it working/success debugin in Visual Studio.

The source project is save here:
http://sourceforge.net/projects/aokts/postdownload?source=dlp
It is program to edit scenario for game AOK.

So when I open aokts.log I see this messages:

http://paste.ofcode.org/3ba4UDw8UpjR8QvkMHmjpX6

I got message that there is missing aokts.exe which is silly, because the aokts.exe is the program which should be built. Also I see there are missing some files like
zlib.h
but this one was not even in the old versions but there is some zlib1.dll and libexpatw.dll so I don't know how to make this working.

I actually want to try to get some class from the source code, if I could be able to decode the scenario file to get object/units into array.

aokts.exe is missing because the solution could not be built due to errors.zlib.h is used for compression as you already know, but wth is libexpatw.dll error? it is required for HP printers.Did you download the solution correctly?
 

h4ever

Member
Aug 30, 2013
163
0
0
aokts.exe is missing because the solution could not be built due to errors.zlib.h is used for compression as you already know, but wth is libexpatw.dll error? it is required for HP printers.Did you download the solution correctly?

I looked into this file originally because I thought it could to reading of the binary data in which the scenario is saved (probably). I don't think it is annything common with HP. I looked into the content and find some msdn functions relative to http://msdn.microsoft.com/en-us/library/System.IO.Stream.aspx
I am convinced that at least one dll is made by Digit (author of the code) and it serves to read the scenery. At lease zlibfile is the library needed to read scenario and in is included by scen.cpp . scen.cpp does main action relative to reading scenario terrain, units, Artificial Intelligence, and similar things.

But the release he made should be completed so makes me no sense why these files are missing...
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
I looked into this file originally because I thought it could to reading of the binary data in which the scenario is saved (probably). I don't think it is annything common with HP. I looked into the content and find some msdn functions relative to http://msdn.microsoft.com/en-us/library/System.IO.Stream.aspx
I am convinced that at least one dll is made by Digit (author of the code) and it serves to read the scenery. At lease zlibfile is the library needed to read scenario and in is included by scen.cpp . scen.cpp does main action relative to reading scenario terrain, units, Artificial Intelligence, and similar things.

But the release he made should be completed so makes me no sense why these files are missing...

When you open the solution do you find the zlib header file?
 

h4ever

Member
Aug 30, 2013
163
0
0
Why every time I try to debug I got message that the exe file does not exists? When I did not rebuild the project. But I wanted to test/debug without building. This way I have rebuild every time when I want to test.

Also why I got error here?
on the line
cout << t ;

Code:
#include <iostream>
#include <conio.h>
using namespace std;
/*
string test(string hello)
{
    return hello;
}
*/
int main()
{
string t;
t="aaaa";
cout << t ;
getch();
return 0;
}
 

h4ever

Member
Aug 30, 2013
163
0
0
Hello,
Can you tell me how can I save the project to share it on net? I have loaded a project from which I removed some files. I noticed that if I would simply just copy files and directories it would not save the project, because there is difference in the files organization and the files which I see in Solution Explorer. I simply want programers to see exactly what I have in my project.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Hello,
Can you tell me how can I save the project to share it on net? I have loaded a project from which I removed some files. I noticed that if I would simply just copy files and directories it would not save the project, because there is difference in the files organization and the files which I see in Solution Explorer. I simply want programers to see exactly what I have in my project.
If the files are organized in a parent/child directory structure; then zip up the structure and go from there.

If you scattered the files all over your system; then cleanup your design and proceed with the first option.

Most IDEs try to create a proper directory structure and as you add new files; they go into that structure by default unless you dictate otherwise.
The only problem you have is when you use premade directories.

Therefore you then need to ensure that those "external" directories are accounted for in your package. Or fold those externals into the primary structure.
 
Last edited: