|
You need to include this file
#include "windows.h"
jhaga
|
|
|
|
|
That will work but since he said MC++ app, I am assuming he wants to use MC++ to do it (i.e. managed code). The way to do this in managed code is to use the BCL class System::Diagnostics::Process class like this:
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int _tmain()
{
Process::Start("Notepad.exe");
return 0;
}
------------------------------
Sam Gentile
Microsoft .NET Consultant
•Web Site : http://www.samgentile.com/
•My O'Reilly Articles: http://www.oreillynet.com/pub/au/1070
• Read my .NET Web Blog! http://dotnetweblogs.com/sgentile/
• Come hear me speak at Win-Dev! http://butrain.bu.edu/windev/bios.asp
----------------------------
|
|
|
|
|
I am losing some of the code with HTML formatting:
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int _tmain()
{
Process::Start("Notepad.exe");
return 0;
}
------------------------------
Sam Gentile
Microsoft .NET Consultant
•Web Site : http://www.samgentile.com/
•My O'Reilly Articles: http://www.oreillynet.com/pub/au/1070
• Read my .NET Web Blog! http://dotnetweblogs.com/sgentile/
• Come hear me speak at Win-Dev! http://butrain.bu.edu/windev/bios.asp
----------------------------
|
|
|
|
|
Hi All, wondering if someone could take a look at the below function and give me any clues as to why the output shows nothing.
I've passed through a sentence (no more than 100 characters) called sentence, which was input by the user. I'm trying to take each word, alphabetize it, and display the number of characters for each.
Thanks for any help!
<br />
void countOfChars(char sentence[]) <br />
{<br />
char *words = strtok(sentence," ");<br />
char *alphaArray[maxWords], *swap;<br />
int wordCount=0;<br />
<br />
cout << "\n\nWORD\t\t" << "Characters" << endl;<br />
<br />
while (words!=NULL) {<br />
wordCount++;<br />
words = strtok(NULL, " ");<br />
}<br />
alphaArray[wordCount] = words;
for (int i=0; i<wordCount-1; i++) {<br />
for (int j=0; j<wordCount-1; j++) {<br />
if (alphaArray[i] > alphaArray[i+1])<br />
swap = alphaArray[i+1];
alphaArray[i+1]=alphaArray[i];<br />
alphaArray[i]=swap;<br />
}}<br />
for (int x=0; x<wordCount; x++) { <br />
cout << alphaArray[x] << "\t\t" << strlen(alphaArray[x]) << endl;<br />
words = strtok(NULL, " ");<br />
}<br />
cout << endl;<br />
}<br />
Sheshi
|
|
|
|
|
// bubbelsort.cpp : Test use only
// Warning. Pointer handling, memory allocation and strtok() are bad
#include "string.h"
#include <iostream.h>
void countOfChars(char sentence[]) ;
int main(int argc, char* argv[])
{
const int buf_size = 1000;
char sName[buf_size]="a one a two";
//cout << "\n Enter max 50 words <each max 20 chars>:" << endl;
//cin.getline(sName, buf_size); // get the input line
countOfChars(sName);
}
void countOfChars(char sentence[])
{
char *words = strtok(sentence," ");
char *alphaArray[101]; // max 100 words
char *swap=NULL;
int wordCount=0;
while (words!=NULL) { // fill array
alphaArray[wordCount]=words;
wordCount++;
words = strtok(NULL, " ");
}
for (int i=0; i<wordCount; i++) { // bubbelsort the pointers
for (int j=i+1; j<wordCount; j++) {
if (*alphaArray[i]>*alphaArray[j])
{
swap=alphaArray[i];
alphaArray[i] = alphaArray[j];
alphaArray[j]=swap;
}
}
}
cout << "\n\nWORD\t\t" << "Characters" << endl; // display
for (int x=0; x <wordCount ; x++) {
cout << alphaArray[x] << "\t\t" << strlen(alphaArray[x]) << endl;
}
}
|
|
|
|
|
What is "this" pointer exactly?
Basil
|
|
|
|
|
a pointer to the class in context.
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|
|
The this pointer is a pointer to the object its' self (that is secretly pass to a method/function).
Here are 2 examples that might help you understand:
Example using C:
//explicitly passing pointer to data object.
void func(struct structName* pData,int newID)
{
pData->ID = newID;
}
Example(s) using C++:
void func(int newID)
{
this->ID = newID;
}
OR
void func(int newID)
{
ID = newID; //"this->" is impiled if ID is member of class
}
Trust in the code Luke. Yea right!
|
|
|
|
|
Compiling i always receive the error message:
"DLLista::Component" no appropriate default constructor
what's wrong??
//DLLista.h
class DLLista : public Lista
{
public:
DLLista(Index n, BaseNode * V);
virtual ~DLLista();
class Component
{
public:
Component * next;
Component * prev;
BaseNode Element;
Component (BaseNode E);
};
};
//DLLista.cpp
DLLista::DLLista(Index n, BaseNode * V) : Lista(n, V){
};
DLLista::Component::Component(BaseNode E){
next=null;
prev=null;
Element=E;
};
DLLista::~DLLista(){};
//lista.h
class BaseNode
{
public:
BaseNode(){ indice = 0; };
private:
Index indice;
};
class Lista
{
public:
/* costruttore/distruttore */
Lista ( Index n, BaseNode * V );
~Lista();
}
|
|
|
|
|
Please avoid posting non-MC++ questions here. The code is full of arrangement problems. Also, there is nothing in "null" defined in C++. It should be "NULL"
Here is a simple rearranged codes which compiles successfully with VS.NET 2003, I am currently using:
typedef int Index;
class BaseNode
{
public:
BaseNode(){ indice = 0; };
private:
Index indice;
};
class Lista
{
public:
Lista ( Index n, BaseNode * V )
{
}
~Lista()
{
}
};
class DLLista : public Lista
{
public:
DLLista(Index n, BaseNode * V);
virtual ~DLLista();
class Component
{
public:
Component * next;
Component * prev;
BaseNode Element;
Component (BaseNode E);
};
};
DLLista::DLLista(Index n, BaseNode * V) : Lista(n, V){
};
DLLista::Component::Component(BaseNode E){
next=NULL;
prev=NULL;
Element=E;
};
DLLista::~DLLista(){};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hello All,
Anyone got custom control toolbox icon/bitmap working and will like to share his/her experience. I need support not requiring direct loading from a file on a disk, but bitmap/icon in a resource.
It is very easy with VB.NET/C#
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I'm not sure if this will workin MC++, but it should (i know its C#):
namespace nBASS {
[ToolboxBitmap(typeof(nBASS.BASS), "nBASS.BASS.bmp")]
public class BASS : Component
{
The bitmap is named BASS.bmp and is an embedded resource, added via solution tab. Note the default namespace gets added automatically.
HTH
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Thanks.
I have being playing with something similar with success, may be I have to reexamine the implementation.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I didnt realise that adding managed resources was so difficult in a MC++ project. C# is such a breeze
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi
Pretty self explanetory I have some C code compiled as unmanaged in the assembly, now all those methods show up as public and static global members. How can I make these private without wrapping them in a C++ (gc or nogc) class?
Thanks
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
There is no hidding process in the assembly. I do not know but try unmanaged #pragma
#pragma unmanaged
...
#pragma managed
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Done that, didnt work For some reason my .h includes's from the CRT have disappeared, but all my own methods are there it would be possible for anyone to execute them via reflection.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I figured it out.
To make a wrapper of this C component (compilied in C) I went and changed all the settings, where all I had to do was a set my wrappers file to compile as /clr and C++. Beautiful The only methods shown are the C methods use by MC++. This way u dont have to mess with pragma blah/that .
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
i use the visual C++, and i want to someone tell me what is the best
Para seguir la trayectoria:
mira al maestro,
sigue al maestro,
camina junto con el maestro,
mira a través del maestro,
conviértete en el maestro
(this is a poor traduction)
To make you trayectory:
Look your master
Follow your master
walk whit your master
look across you master
become in your master
|
|
|
|
|
I am not sure what this has to do with "C and C++ compilers". I agree that [this is poor translation] (this is a poor traduction). I will ask Isrial, are main technition, if he is willing to help, since he is from a country near yours'.
I can not garantee he will be interested.
|
|
|
|
|
Visual C++, claro.
jhaga
(P. Watson)
... and the roar of John Simmons own personal Nascar parked in the garage. Meg flitting about taking photos.Chris having a heated arguement with Colin Davies and .S.Rod. over egian values (or something.) Nish manically typing away at a nearby keyboard. Duncan racing around after his pet rat *censur* Michael Martin and Bryce loudly yelling *censur* C.G. having a fit as Roger Wright loads up Visual Basic. Anna waving *censur* and Deb scoffing chocolates in the corner.
.Good heavens!
|
|
|
|
|
Hi!
I have a class that contains several nested structs:
<code>
public __abstract __gc class Foo
{
public:
__value struct Struct1
{ /** };
__value struct Struct2
{ /** };
__value struct Struct3
{ /** };
__value struct Struct4
{ /** };
[...]
};
</code>
However, that maximum number of nested structs seems to be 17. Whenever I add the 18ths struct, I get an internal compiler error.
Is this a confirmed bug?
Regards,
Andre
|
|
|
|
|
Just test 21 nested structs on VS.NET 2003 Final Beta. It compiles without any problem.
Frankly, working with MC++ is sometimes frustrating. The compiler seems to be a work in progress.
Consider the ff, for instance:
System::String __gc* strTmp1 = String::Format(S"{0}, {1}, {2}",
S"0", S"1", S"2");
System::String __gc* strTmp2 = String::Format(S"{0}, {1}, {2}, {3}",
S"0", S"1", S"2", S"3");
The second strTmp2 will not compile simply because the MC++ does not have support for variable parameters, while C# and even VB.NET supports it.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I have a managed class and I want to declare a jagged array of doubles as a member. How do I declare this and how do I initialize it? I can do that in C#, but I have syntax problems when it comes to __gc stuff
Thanks!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
__wchar_t comma __gc[] = {L','};
|
|
|
|