|
You could search the articles here at Code Project.
Drugs are bad, mmmmkkkkkk
Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it.
|
|
|
|
|
Hey I need lots of money, how much can you offer?
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Is better you ask about your problem not I need to a code.You can starting to write it and if you have problem then ask about your problem
|
|
|
|
|
You have several issues.
1 - this is the C++/CLI forum. If there's a place for C questions, it, by definition, is not here
2 - this sounds like a reasonably complex task. One has to ask how you got this far in your course, if you can't read.
3 - We're not here to do your homework, and if we did do it, you wouldn't be learning, now would you ?
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 )
|
|
|
|
|
please tell me that
can we define a function outside the main() in c language
please give an example
thanks
hi
|
|
|
|
|
paras_s12 wrote: can we define a function outside the main()
And how it can be defined inside main ?
This question is out side scope of this forum. Rather ask in VC++[^] forum.
|
|
|
|
|
prasad_som wrote: This question is out side scope of this forum. Rather ask in VC++[^] forum.
It's outside the scope of that forum too
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
can anybody tell me abt this
hi
|
|
|
|
|
Would you mind posting it in correct forum ?
|
|
|
|
|
please sir tell me in which forum i will put this one
hi
|
|
|
|
|
This forum is for Managed c++/cli
Your c question must be in Visual C++ forum here on CP.
|
|
|
|
|
|
shut your big mouth and open your ears
|
|
|
|
|
I've better question:
Can we define a function inside the main() in c language?
buahaha
|
|
|
|
|
paras_s12 wrote: can we define a function outside the main() in c language
you ar eon wrong forum dude... try http://www.codeproject.com/script/comments/forums.asp?forumid=1647
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I had written :
for(int i=0; i <10; i++){<br />
em[i]->pct = (gcnew System::Windows::Forms::PictureBox());<br />
em[i]->pct->Location = System::Drawing::Point(250, 250);<br />
em[i]->pct->Visible = true;<br />
em[i]->pct->Size = System::Drawing::Size(50, 50);<br />
}
And I got this error :
An unhandled exception of type 'System.NullReferenceException' occurred in Little tanks.exe
Additional information: Object reference not set to an instance of an object.
at this line : em[i]->pct = (gcnew System::Windows::Forms::PictureBox());
what did I do wrong?
|
|
|
|
|
How have you defined the em array?
|
|
|
|
|
em[i] is null, you probably created an array and didn't create the objects in it
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 )
|
|
|
|
|
the em array defined so : static array<tank^>^ em;
and tank is structure :
ref struct tank {<br />
int step_x, step_y; <br />
System::Windows::Forms::PictureBox^ pct;<br />
};
What do you mean saying to create objects for array?
|
|
|
|
|
thesad wrote: static array^ em;
You have not initialized array here.
Array can be initialized as given in MSDN example.
array<MyClass ^> ^ MyArray = gcnew array<MyClass ^>(100);
|
|
|
|
|
I wrote taht you had sad, but still at same line is that error
|
|
|
|
|
Would interesting to see, how you have done that. There are two possiblitites,
1. You have not allocated memory for it.
2. You are accessing invalid index.
|
|
|
|
|
Here is all code :
<br />
#pragma once<br />
namespace Littletanks {<br />
ref struct tank {<br />
int step_x, step_y; <br />
System::Windows::Forms::PictureBox^ pct;<br />
};<br />
using namespace System;<br />
using namespace System::ComponentModel;<br />
using namespace System::Collections;<br />
using namespace System::Windows::Forms;<br />
using namespace System::Data;<br />
using namespace System::Drawing;<br />
public ref class wnd_main : public System::Windows::Forms::Form {<br />
public: wnd_main(void) {<br />
InitializeComponent();<br />
}<br />
protected: ~wnd_main() {<br />
if (components) delete components;<br />
}<br />
private: System::ComponentModel::IContainer^ components;<br />
private: int max_x, max_y, min_x, min_y;<br />
private: tank usr, b_usr;<br />
private: static array<tank^>^ em; <br />
private: static array<tank^>^ b_em; <br />
<br />
#pragma region Windows Form Designer generated code<br />
void InitializeComponent(void)<br />
{<br />
this->components = (gcnew System::ComponentModel::Container());<br />
this->usr.pct = (gcnew System::Windows::Forms::PictureBox());<br />
this->b_usr.pct = (gcnew System::Windows::Forms::PictureBox());<br />
this->SuspendLayout();<br />
this->usr.pct->Location = System::Drawing::Point(235, 391);<br />
this->usr.pct->Size = System::Drawing::Size(50, 50);<br />
this->usr.pct->TabStop = false;<br />
array<tank^>^ em = gcnew array<tank^>(10);<br />
array<tank^>^ b_em = gcnew array<tank^>(10);<br />
for(int i=0; i <10; i++){<br />
this->em[i]->pct = gcnew System::Windows::Forms::PictureBox();<br />
this->em[i]->pct->Location = System::Drawing::Point(250, 250);<br />
this->em[i]->pct->Visible = true;<br />
this->em[i]->pct->Size = System::Drawing::Size(50, 50);<br />
this->b_em[i]->pct = gcnew System::Windows::Forms::PictureBox();<br />
this->b_em[i]->pct->Load("b_em[i]->jpg");<br />
this->b_em[i]->pct->Location = System::Drawing::Point(13, 64);<br />
this->b_em[i]->pct->Size = System::Drawing::Size(5, 5);<br />
this->b_em[i]->pct->Visible = false;<br />
this->Controls->Add(this->b_em[i]->pct);<br />
this->Controls->Add(this->em[i]->pct);<br />
} <br />
this->b_usr.pct->Load("b_usr.jpg");<br />
this->b_usr.pct->Location = System::Drawing::Point(97, 142);<br />
this->b_usr.pct->Size = System::Drawing::Size(5, 5);<br />
this->b_usr.pct->Visible = false;<br />
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);<br />
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;<br />
this->BackColor = System::Drawing::SystemColors::Window;<br />
this->ClientSize = System::Drawing::Size(500, 500);<br />
this->MaximizeBox = false;<br />
this->MinimizeBox = false;<br />
this->Controls->Add(this->b_usr.pct);<br />
this->Controls->Add(this->usr.pct);<br />
this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &wnd_main::wnd_main_KeyDown);<br />
this->Name = L"wnd_main";<br />
this->Text = L"Little tanks ";<br />
this->statusStrip1->ResumeLayout(false);<br />
this->statusStrip1->PerformLayout();<br />
this->menuStrip1->ResumeLayout(false);<br />
this->menuStrip1->PerformLayout();<br />
this->ResumeLayout(false);<br />
this->PerformLayout();<br />
}<br />
#pragma endregion<br />
|
|
|
|
|
Here, you had made couple of mistakes,
thesad wrote: array^ em = gcnew array(10);
array^ b_em = gcnew array(10);
Here, again you are defining local variables. It should be like this,
this->em = gcnew array<tank^>(10);
this->b_em = gcnew array<tank^>(10);
Again, simply defining array doesn't initializes its members, you need to allocate tank variable for each index. So, your code can be modified like this,
thesad wrote: for(int i=0; i <10; i++){
this->em[i]->pct = gcnew System::Windows::Forms::PictureBox();
this->em[i]->pct->Location = System::Drawing::Point(250, 250);
Modify this to,
for(int i=0; i <10; i++){
em[i] = gcnew tank;
this->em[i]->pct = gcnew System::Windows::Forms::PictureBox();
this->em[i]->pct->Location = System::Drawing::Point(250, 250);
|
|
|
|
|
thank you for your help
|
|
|
|