|
I want to use the Visual studio C++ 2005, but for standard c\c++ code, can I do it, can I turn the mixed code off, I want only native C\C++ code to be compiled and used, I don't want at future to use .net assemblies.
|
|
|
|
|
Yes, you can build native apps with 2005 (and 2003 and 2002)
|
|
|
|
|
|
This code runs fine.
When it's run, output says Struct A's size is 16 and Struct B's size is 12, even though
both contain 2 ints and 2 chars each.
Can someone tell me how the heck that is possible?
#include "stdafx.h"
#include <iostream>
using namespace std;
struct
{
char c1;
int i1;
char c2;
int i2;
}a;
struct
{
int i1;
int i2;
char c1;
char c2;
}b;
int main()
{
cout<<"sizeof struct A " <<sizeof(a);
cout<<"sizeof struct B " <<sizeof(b);
getchar();
return(0);
}
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
Wrong forum. Ask in VC++[^] forum instead.
|
|
|
|
|
Bulky Fellow wrote: What rubbish? Does that code look anything like VC++ to you? I guess
one look at the
first include must have fooled you. Did you even bother reading the
code?
If you can't solve something (and also give wrong directions like a
jackass), just
shut up and sit still instead of blabbering.
I'm not sure, why you have deleted this post ? If you think, this is right forum for this question, why you have posted it in VC++ fourm again.
You have not read sticky post by Chris[^] , before posting this question.
I wanted you to get good answers, thats why was directing you to VC++ forums.
|
|
|
|
|
Hi,
I have a Client-Server Application. I am trying to get the IP address of the machine on which the client is running on at the Server Side. I want to store the IP address at the Server side and use it for future processing.
How to get the IP address of the client machine.
I am using VC++ 6.0
Thanks n regards
-- modified at 4:49 Monday 26th February, 2007
|
|
|
|
|
Use gethostbyname name.
MSDN has this example given,
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
void main()
{
WSADATA wsaData;
char szHostname[100];
HOSTENT *pHostEnt;
int nAdapter = 0;
struct sockaddr_in sAddr;
if (WSAStartup(0x0101, &wsaData))
{
printf("WSAStartup failed %s\n", WSAGetLastError());
return;
}
gethostname( szHostname, sizeof( szHostname ));
pHostEnt = gethostbyname( szHostname );
while ( pHostEnt->h_addr_list[nAdapter] )
{
memcpy ( &sAddr.sin_addr.s_addr, pHostEnt->h_addr_list[nAdapter],
pHostEnt->h_length);
printf("Name: %s\nAddress: %s\n", pHostEnt->h_name,
inet_ntoa(sAddr.sin_addr));
nAdapter++;
}
WSACleanup();
return;
}
Vichitram wrote: I am using VC++ 6.0
You should have asked this question in VC++ forum.
|
|
|
|
|
Vichitram wrote:
I am using VC++ 6.0
Then you're plainly not using C++/CLI
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I am trying to use a FolderBrowserDialog to get a folder and set the path to a text field on my form. The first problem I came up against was a blank folder listing which I had to rectify by making the FolderBrowserDialog spawn as a STA ApartmentState. Now the problem is that I can't get the SelectedPath back onto my calling form.
Here is my code for my Click event to open the FolderBrowserDialog and the subsequent settings:
private: System::Void OnClicked_ID_GETPHOTO_DIR(System::Object^ sender, System::EventArgs^ e) {<br />
Thread^ newThread = gcnew Thread ( gcnew ThreadStart( this, &Picture_Importer::Form_Start::Get_Directory ) );<br />
newThread->SetApartmentState(ApartmentState::STA);<br />
newThread->Start();<br />
}<br />
<br />
private: void Get_Directory() {<br />
this->folderBrowserDialog1->SelectedPath = "c:\\";<br />
<br />
this->folderBrowserDialog1->Description = "Select the directory that you want to use as the default.";<br />
<br />
this->folderBrowserDialog1->ShowNewFolderButton = false;<br />
<br />
System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();<br />
if ( result == ::DialogResult::OK )<br />
{<br />
folderName = folderBrowserDialog1->SelectedPath;<br />
this->ID_PHOTO_DIR->Text = folderName;<br />
}<br />
<br />
}
The problem is when I run the code and it gets to this->ID_PHOTO_DIR->Text = folderName; it chokes with
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll<br />
<br />
Additional information: Cross-thread operation not valid: Control 'ID_PHOTO_DIR' access from a thread other than the thread it was created on.
I am new to this programming language, so please be gentle with me. I appreciate what the message is saying I just don't get how to fix it.
|
|
|
|
|
|
Hi!!
I've been reading about multithreading in this page, but i can't compile the example written here.
I'm using Borland C++ 5.5.1 for Win32 and my config files are
bcc32
-I"C:\Borland\BCC55\Include"<br />
-L"C:\Borland\BCC55\Lib;C:\Borland\BCC55\Lib\PSDK<br />
-P<br />
-v-<br />
-w<br />
-D_WIN32_WINNT=0x0400
Ilink32
-v-<br />
-x<br />
-L"C:\Borland\BCC55\Lib;C:\Borland\BCC55\Lib\PSDK;C:\WINDOWS\system32"
And the error that the compiler gives me is
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland<br />
thread.c:<br />
Error E2268 thread.c 30: Call to undefined function '_beginthread' in function main()<br />
Error E2268 thread.c 46: Call to undefined function '_endthread' in function ThreadProc(void *)<br />
*** 2 errors in Compile ***<br />
can someone help me??
what am i doing wrong??
i'am a beginner in multithreading...
greetings!!
|
|
|
|
|
venetus wrote: I'm using Borland C++ 5.5.1
Then you can't possibly be using C++/CLI. You could try the visual C++ forum, but a Borland forum would be more sensible, if there is one.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
As I can see there is no problem with multithreading, but with the functions You've used. Compiler doesn't know these functions. Have you included <process.h> ??
|
|
|
|
|
i just copy and pasted the example...
what do you think i have to include???
|
|
|
|
|
i've just compile the example with Dev and it worked. But i don't know why it doesn't work with Borland compiler...
Any hint?
|
|
|
|
|
Which example? There are 3 examples
|
|
|
|
|
this one "Download demo project in C - 3 Kb"
bye
|
|
|
|
|
I've tried it with Builder 6.0 and it's worked fine.
Probably you haven't checked the Multi Threaded check box in File\new\other...\console wizard dialog. Make sure it's checked.
|
|
|
|
|
this is STILL the wrong forum to be talking about this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i would add a dll in my project but i don't know how i can introduce him, iam viewing a reference but i can't add him, i work with Visual Studio 2005 please help me.
Thank you very mutch.
|
|
|
|
|
What is the DLL written in ? You can add references to COM dlls and .NET dlls ( assuming your question is in the right forum and you are using C++/CLI ), I don't think you can import plain dlls, you can p/invoke them ( again, if you really are using C++/CLI ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hey guys,
few days ago somebody ask me that where it is mandatory to define copy constructor i.e without making an explicit call we can not solve our problem..
so i need to know what would be that condition as i am also searching for the same from 2-3 days ...
if anybody can help me in getting the answer i'll greateful to him/her..
Thank you
Regards,
Pankaj Sachdeva
|
|
|
|
|
pan_angel wrote: where it is mandatory to define copy construc
It is not mandateroy to define copy c'to. But, it is required to define in cases where, one of member variable is pointer and uses dynamic memory allocation.
class A
{
char *m_pName;
int m_nid;
public:
A(char *pName,int nId)
{
m_pName = new char [strlen(pName)+1] ;
strcpy(m_pName,pName);
nid = nId;
}
~A()
{
delete []m_pName;
m_pName = NULL;
}
};
int main()
{
A aObj("Prasad",1);
A aObj1 = aObj;
}
So should modify your defintion to,
class A
{
char *m_pName;
int m_nid;
public:
A(char *pName,int nId)
{
m_pName = new char [strlen(pName)+1] ;
strcpy(m_pName,pName);
m_nid = nId;
}
A(A& aObj)
{
int nMemoryToAlloacate = strlen(aObj's char pointer);
m_pName = new char [nMemoryToAlloacate + 1] ;
strcpy(m_pName,aObj's char pointer);
m_nid = aObj's m_nid ;
}
~A()
{
delete []m_pName;
m_pName = NULL;
}
};
|
|
|
|