|
Thank you for posting your class assignment we all find it very interesting... NOT
led mike
|
|
|
|
|
You actually typed in your entire homework assignment ? That's hilarious.
It doesn't matter, but you also posted in the wrong forum. But, where-ever you posted this, you won't get us to do your homework. If you want people to do your homework for you, I suggest cutting out a wasted 4 years and applying for work at McDonalds now.
Or, you could try to do your own homework, then we'd love to help you. Help is different to laziness.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have a application communicating to the hardware device via serial port.I have to do a task(some work) at the specified interval of time continously.
So i opted to use System.Timers. whenever the time elapses,i will perofrm the task.Apart from this i have someother task running parallely in my application.
The timer doesn't elapse at the speciifed time when some other task is going on continously.This is due to the time slice that OS schedules for the thread to execute .
But how can i make my task to execute when the timer elpases.Can i set some priority to the timer.Is there any alternate way to do this.
Thanks in Advance,
Sangeetha
|
|
|
|
|
Timers are a low priority message so can be delayed if other things are occurring, you could use a callback function instead, or a thread which wakes up after a specific amount of time.
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
in the name of god
hi.
for commercial game what is language programing for next year? c# or c++.
|
|
|
|
|
|
Most modern games are programmed in C++, and I personally believe that this trend will continue for at least the next several years. For C# gaming, Microsoft is working on a project called XNA[^]. It's actually pretty cool; go check it out.
(As an aside, this website has information on Quake II for .NET[^]. This is likely a good starting point if you're interested in building games using C++/CLI.)
|
|
|
|
|
I have a program that is able to take the numbers out of the .txt if it is just a list of numbers. Problem is, I have a file with Names before the grades. I believe i need to set up another array inside the first one to fill with names. The .txt file will look like:
Name
grade
grade
grade
grade
grade
grade
grade
grade
grade
grade
Name
...
Have 15 Names with 10 grades under each. I guess what i'm trying to do is take the strings out of the file. Is there a way to take the strings(there is a string every 11 lines)
Here is what i have now:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
const int TESTS = 10;
const int STUDENTS = 15;
void displayGrades( int [][TESTS] );
void getGrades( int [][TESTS]);
int main()
{
int data[STUDENTS][TESTS] = {0};
getGrades( data );
cout <<fixed <<setprecision(1);
displaygrades(="" data);
#ifdef="" win32
system("pause");
#endif
return="" 0;
}
void="" getgrades(int="" data[]="" [tests])
{
ifstream="" inputfile;
inputfile.open("gradespring07.txt");
if="" (!inputfile)
{
cout="" <<="" "error="" opening="" file!"="" endl;
exit(="" 1="" );
}
for="" (int="" student="0;" student<="" students="" ;="" student++)
{
for="" test="0;" test<tests;test++)
{
inputfile="">> data[student][test];
}
}
}
void displayGrades( int data[][TESTS] )
{
double testTotal = 0.0;
double classTotal = 0.0;
double squared = 0.0;
double var = 0.0;
double sdev = 0.0;
int mxm = data[0][0];
int min = data[0][0];
cout << "\nGrade summary" << endl;
cout << "--------------" << endl;
cout << left << setw(7) << "Student"
<< right << setw(5) << right << "Ex1"
<< setw(7) << "Ex2"
<<setw(6) <<="" "ex3"
<<setw(6)="" "qz1"
<<setw(5)="" "qz2"
<<setw(6)="" "qz3"
<<setw(6)="" "qz4"
<<setw(6)="" "qz5"
<<setw(6)="" "pr1"
<<setw(6)="" "pr2"
<<setw(8)="" <<"averg"="" <<endl;
for="" (="" int="" student="0;" <="" students;="" ++)
{
cout="" left="" <<setw(7)="" +="" 1;
for="" test="0;" tests;="" test++)
{
int="" grade="data[student][test];
cout" right="" <<setw(5)="" <<"="" ";
classtotal="" average="(((data[student][0]+data[student][1]+data[student][2])/3)*0.4)+(((data[student][8]+data[student][9])/2)*0.3)+(((data[student][3]+data[student][4]+data[student][5]+data[student][6]+data[student][7])/5)*0.3);
cout" setw(7)="" endl;
}
cout="" "\n"="" "test="" avg";
for="" (int="" test++)
{
for="" student++)
{
testtotal="" setw(6)="" testtotal="" students;
testtotal="0.0;
}
cout" endl;
cout="" "stan="" dev";
for="" student++)
{
squared="" 2.0);
var="(squared" -="" ((testtotal="" *="" testtotal)="" 15)="" )="" 15;
sdev="sqrt(var);
}
cout" sdev;
sdev="0.0;
}
cout" "max";
for="" student++)
{
if="" (data[student][test]=""> mxm)
{
mxm = data[student][test];
}
}
cout << right <
|
|
|
|
|
This is Managed C++/CLI forum. Post it to VC++/MFC forum. You may get some replies there.
Best,
Jun
|
|
|
|
|
Dear all:
I need to write a C++ code such that when I put speak to mic, the speaker will echo my voice immediately (actually 2 seconds of delay is OK, even microsoft's sound card test wizard delays 1 second). Is there any code avaialable on CodeProject (I can't find one)? If not, is there any recommendation on how I can write out the code?
|
|
|
|
|
The simplest way is probably using the Waveform-Audio Interface[^]
Essentially, after setting up capture and playback devices, you can loop using waveInAddBuffer()
to get buffers filled with audio samples and pass the returned buffers to waveOutWrite() to be
played back.
BTW, the one second delay is on purpose...you can get much lower latency.
Mark
|
|
|
|
|
hi
i have to write a program of a puzzle in C++/object oriented programming
but i dont know how to write its code.
the puzzle would be like that it contain 15 random no.s and the user will arrange the puzzle by the arrow kews on the key board.
i know that i have to use ascii avlues also but i could not write it till now
i request u to kindly help me out .
scorpion in style
|
|
|
|
|
scorpioninstyle wrote: i have to write a program of a puzzle in C++/object oriented programming
Then you're in the wrong forum
scorpioninstyle wrote: but i dont know how to write its code.
Then you're going to fail this assignment. Learn from this, and pay more attention in class in future.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
if i press F4, i see active process list in linux keyboard. Please help.
static int emulate_raw(struct vc_data *vc, unsigned int keycode,
unsigned char up_flag)
{
if (keycode > 255 || !x86_keycodes[keycode])
return -1;
switch (keycode) {
case KEY_PAUSE:
put_queue(vc, 0xe1);
put_queue(vc, 0x1d | up_flag);
put_queue(vc, 0x45 | up_flag);
return 0;
case KEY_HANGUEL:
if (!up_flag) put_queue(vc, 0xf1);
return 0;
case KEY_HANJA:
if (!up_flag) put_queue(vc, 0xf2);
return 0;
}
if (keycode == KEY_SYSRQ && sysrq_alt) {
put_queue(vc, 0x54 | up_flag);
return 0;
}
if (x86_keycodes[keycode] & 0x100)
put_queue(vc, 0xe0);
put_queue(vc, (x86_keycodes[keycode] & 0x7f) | up_flag);
if (keycode == KEY_SYSRQ) {
put_queue(vc, 0xe0);
put_queue(vc, 0x37 | up_flag);
}
return 0;
}
|
|
|
|
|
C++/CLI is now on Linux?
You posted in the wrong forum. Your question has a better chance of getting answered in a native C++ forum.
|
|
|
|
|
I got two questions.
First how do I convert a Byte to an unsigned char
and second, is there a good tutorial or something to learn when to use wich method of conversion or a list of all conversion because I often run into a problem like this and I try a couple of methods I know an I get frustrated because it doesn't work often or give weird result.
|
|
|
|
|
samkook wrote: First how do I convert a Byte to an unsigned char
A BYTE *is* an unsigned char.
samkook wrote: and second, is there a good tutorial or something to learn when to use wich method of conversion or a list of all conversion because I often run into a problem like this and I try a couple of methods I know an I get frustrated because it doesn't work often or give weird result.
Really, you just need to understand what the methods you use ( such as casting ) are doing.
If you didn't post this in the wrong forum, the Convert class has lots of conversions, which it will try to make if possible for you. If you posted this in the wrong forum ( you're not using managed C++ ) then don't worry about this bit, but try to ask in the right forums in future.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I posted in this forum because i'm using a mix of managed and not managed c++, but it's true that my question wasn't about managed, sorry.
And I also tought that BYTE was the same thing as unsigned char, but since i can't put a byte into an unsigned char like this: unsignedCharVar = BYTEVar , I was having doubts. So my question is how can I put a byte var into an unsigned char one(and no I can't use the byte directly, I need to test something)
Here is exactly what I tried:
UINT iFileLength = fFile.GetLength();
LPBYTE pByteBuff = new BYTE[iFileLength];
unsigned char cByteBuff[1];
UINT iCompteur = 0;
cByteBuff = pByteBuff[iCompteur-1];
|
|
|
|
|
samkook wrote: I posted in this forum because i'm using a mix of managed and not managed c++, but it's true that my question wasn't about managed, sorry.
That's cool, if you're using managed, then the only issue is, more people would see if you posted in the other forum
samkook wrote: but since i can't put a byte into an unsigned char like this: unsignedCharVar = BYTEVar
A BYTE is a typedef, if you need to cast it, I'd be really surprised, but if you did, casting it would totally work.
Your problem is completely different. You don't have an unsigned char, you ( for reasons I do not understand ) have an array of unsigned chars, which has a length of one. Why do you need an array ?
You're also setting iCompteur to 0, and trying to go 1 minus that for your index. This will, of course, blow up.
Your problem has nothing to do with conversion between two types ( which are the same ). Don't try to index outside the array (0-1 is outside the array ) and don't try to set an array to equal a value. Set a value IN the array on the left, as you are on the right.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Humm, Sorry about that, I'm not going out of the array, I only didn't put the code where I increment iCompteur. And I was using an array because a function needed it and if I only gave it an unsigned char, it was giving me an error(another case of me doing weird things because I can't find the right conversion).
Also, How do I set the value IN the array. I'm not sure how to do it(forget this line, it was a stupid question).
I just tested what I wanted to test an at my big surprise I was right, it was the problem(now to explain it). I'm reading text from a binary file, and displaying it into an editbox. Before displaying it, I'm putting each bytes into a CString and then I display it. If i Do this: csSpeech += (char *)cByteBuff; it's working and if I do this: csSpeech += (char *)pByteBuff[iCompteur-1]; it's crashing and finally if I do this: csSpeech += (char *)&pByteBuff[iCompteur-1]; all the sentence is reapeated with dropping a letter each time(for exemple if the sentence is abc it will be abcbcc). Any idea of what i'm doing wrong. BTW, before this i'm transfering the value of the byte array(the big one) into the small one.
|
|
|
|
|
samkook wrote: csSpeech += (char *)pByteBuff[iCompteur-1];
Of course this will crash, the index gives you a char, and you tell the computer to look at the address that number represents for a string.
samkook wrote: csSpeech += (char *)&pByteBuff[iCompteur-1];
Why would you do this ? You're getting the address with &, why not just cast to char ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
A few questions from a long time programmer but .NET newbie:
I seem to be having an awful lot of trouble getting a textbox set up that will properly use the userpaint flag. Whenever I set it, I can then override the onPaint and onBackgroundPaint functions and have them do their own thing (such as filling the background with a gradient, which is my immediate goal) but it seems that there is still a lot of things that the textbox control simply draws on it's own without any input from me: Cursors, borders, selected text, etc.
Is there anything further I need to override in order to completely control the control painting, or is this simply one of those things that are *shudder* hardcoded into the system?
Some sample code, for kicks:
<br />
public ref class MyTextBox : public System::Windows::Forms::TextBox<br />
{<br />
public:<br />
MyTextBox (void)<br />
{<br />
this->SetStyle(ControlStyles::UserPaint | ControlStyles::AllPaintingInWmPaint, true);<br />
this->SetStyle(ControlStyles::SupportsTransparentBackColor, true);<br />
this->SetStyle(ControlStyles::OptimizedDoubleBuffer, true);<br />
}<br />
<br />
protected:<br />
~MyTextBox ()<br />
{<br />
if (components) { delete components; }<br />
}<br />
<br />
private:<br />
System::ComponentModel::Container ^components;<br />
<br />
protected:<br />
virtual void OnPaintBackground(PaintEventArgs^ e) override {<br />
Drawing::Brush^ backBrush = gcnew Drawing2D::LinearGradientBrush(<br />
this->ClientRectangle,<br />
Color::AliceBlue, <br />
Color::LightBlue,<br />
Drawing2D::LinearGradientMode::Vertical);<br />
<br />
e->Graphics->FillRectangle(backBrush, this->ClientRectangle);<br />
<br />
delete backBrush;<br />
}<br />
<br />
virtual void OnPaint(PaintEventArgs^ e) override {<br />
System::Drawing::Brush^ tBrush = SystemBrushes::ControlText;<br />
<br />
StringFormat^ tFormat = gcnew StringFormat();<br />
tFormat->Alignment = StringAlignment::Near;<br />
tFormat->LineAlignment = StringAlignment::Near;<br />
tFormat->Trimming = StringTrimming::None;<br />
<br />
e->Graphics->DrawString(this->Text, this->Font, tBrush, this->ClientRectangle, tFormat);<br />
}<br />
A few other questions, if anyone cares to answer:
-Is there a CLI equivalent to the C# "base" keyword? I have plenty of times that I'd like to call something like base.OnPaint(), but there doesn't seem to be a resonable way of doing that in C++/CLI. (For example, in my code above TextBox::OnPaint(e) would NOT work, it would simply call my overridden version.)
-If I declare a virtual function as "new" (as opposed to override), how in the world to I call it? It always seems to default to the function for the class I inherited it from.
-Is there a way that you can just override OnPaintBackground without overriding OnPaint? I thought you could just leave out your own OnPaint definition, but this doesn't appear to work so well in practice (for instance: all my fonts become an ugly bold "system" font)
Thanks in advance for all your help!
|
|
|
|
|
Dear All,
I am not sure whether I should post this question in this forum.
If not please let me know the correct forum to post the question.
I am using CPPUnit::XmlOutputter to write the unit test results to an XML file.
The program works as expected and I can see the test results in the xml file.
But I also want to add intermediate results and user defined messages in the same xml result file.
How do I do that?
Thanks a ton,
Arti gujare
|
|
|
|
|
Hello:
I am developping a MC++ dll that reuses tons of code that was made in unmanaged C++. What I am trying to do now is to store unmanaged objects in a managed collection.
Let's suppose that I have an unmanaged class (from an unmanaged c++ dll)
CMyUnmanaged pUnmanaged* = new CMyUnmanaged;
And, on the other hand I have a .net collection, a hashlist in this case:
System::Collections::Hashlist* hl = new System::Collections::Hashlist;
What I would like to achive is something like this:
hl->Add(pUnmanaged->Name, pUnmanaged);
CMyUnmanaged pUnmanaged2* = hi[pUnmanaged->Name];
But as .net collections can only store System::Objects, that is managed objects, I cannot do it the straight way.
How can I convert my unmanaged pointers in order to store them in the hashlist?
Is there a better way to do this?
Thank you very much!
|
|
|
|
|