|
Thanks. Can you suggest what statment i need in ordr to read from the port?
|
|
|
|
|
Hi,
Delegates raised asynchrnosly does not raise in the invocation order.It executes randomly.How to make this delegate to be raised in the order it is invoked
Thanks in advance
Sangeetha
|
|
|
|
|
Hi,
i tried the CXImage Libary to create a multipage tif file. everything works fine! but for one project i need to split a multipage tif into several tif files.
how can i realise this by using the cximage libary? can anyone help me please?
thanks a lot!
|
|
|
|
|
*sigh* wrong forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
then please take it to the right forum section, or forward it... i dont know where to post else...
thx!
|
|
|
|
|
I'm afraid I can't move posts at the moment, I am having network problems while travelling.
The library in question is not written using C++/CLI, it's written in normal c++. Hence, as the forum for this article is no longer supported, the Visual C++ forum is the place to ask this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Given something like this (assume everything public, VC++ 2003 old syntax)...
__gc class ManagedClass
{
AnotherManagedClass __gc *pAnotherManagedClass;
...
AnotherManagedClass __gc * GetAnotherManagedClass() {return pAnotherManagedClass;}
};
class UnmanagedClass
{
gcroot<ManagedClass *> pManagedClassObj;
...
void UnmanagedClassFunc();
};
Which of the following three is the safest/most-correct/least-overkill way to use the managed
object pointers from an non-GC class method:
void UnmanagedClassFunc()
{
pManagedClassObj->GetAnotherManagedClass()->AnotherManagedClassFunc();
}
or
void UnmanagedClassFunc()
{
gcroot<AnotherManagedClass *> pAnotherManagedClassObj;
pAnotherManagedClassObj = pManagedClassObj->GetAnotherManagedClass();
pAnotherManagedClassObj->AnotherManagedClassFunc();
}
or
void UnmanagedClassFunc()
{
AnotherManagedClass __pin *pAnotherManagedClassObj = pManagedClassObj->GetAnotherManagedClass();
pAnotherManagedClassObj->AnotherManagedClassFunc();
}
Thanks,
Mark
|
|
|
|
|
The first one is fine and is what you need to use.
|
|
|
|
|
Thanks much Nish.
So, pinning is only required if I passed the pointer to another unmanaged function?
There's no chance of the managed object moving during the call? I guess I'm thinking in terms of
a "this" pointer being a C++ guy.
Mark
|
|
|
|
|
Mark Salsbery wrote: So, pinning is only required if I passed the pointer to another unmanaged function?
There's no chance of the managed object moving during the call? I guess I'm thinking in terms of
a "this" pointer being a C++ guy.
Yeah, as long as you are accessing the managed pointer, you don't need to do pinning. But, if you are passing the managed pointer using a native pointer (for instance, when calling a native function), then you need to pin it. Because the native pointer will not be updated when the managed object it is pointing to gets relocated (if it does).
|
|
|
|
|
Ok, thank you very much Nish.
I'm a seasoned C++ programmer so I have "trust issues" with this managed code stuff
(in fact, I spent 6 hours one night convincing myself that garbage collection worked LOL).
I don't want to release code that mysteriously crashes because of some silly thing like this.
Take care!
Mark
|
|
|
|
|
Hi
I have written a plugin but don't know how to register it so that i can use it.
can anybody tell me how can i register a plugin.
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
saqib82 wrote: how can i register a plugin
plug in for what?
led mike
|
|
|
|
|
Write a C++ program that implements a very simple spell checker.
1. Specification
A spell checker is a program that verifies the spelling of words in a document. Your program should prompt the user to input some text, find out which words are misspelled and finally give output as described below.
The following is an example illustrating the behaviour of the program:
csh> ./ex3
Input text (enter END to stop):
Twinkle, twinkle, little ster,
How I wondre what you are
END
Extracted words:
Twinkle,twinkle,little,ster,How,I,wondre,what,you,are
Marked text:
Twinkle, twinkle, little #ster#,
#How# I #wondre# #what# #you# #are#
Input
When the program is executed, the user is requested to input multiple lines of text. The input is stopped when a line containing only "END" is entered. "END" will NOT be treated as part of the input text.
Processing
After the text is input, the program should determine which words are misspelled. A word is defined as a string of letters (upper or lower case) preceded and followed by a non-letter (e.g. space, tab, number,punctuation mark). It also includes strings of letters appearing at the beginning and/or end of a line.
For example, in the following input line:
How I wondre what@you are
Six words can be extracted:
How,I,wondre,what,you,are
After the words are extracted, the program should determine which are misspelled. Please see next section for details about misspelling checking.
replace it with your own information
output 1
output 2
continue inputting until
END is entered
Output
Finally, the program should output two things:
1) The extracted words with each word separated from the next one by a comma. The order of appearance of the words to be output should follow that of the input.
2) The input text with all misspelled words enclosed by a pair of '#'. Nothing else should be added or removed from the output.
2. Misspelling Checking
Your program must include a header file ex3.h which is to be provided by your instructor during marking.
The header file will look like the following:
// example of ex3.h - will be different during actual marking
#define MAX_WORDS 4
char dictionary[MAX_WORDS][20] = { "i", "twinkle", "little", "star" };
Your program must include ex3.h (located at the same directory of your source file) and make use of the
constant MAX_WORDS and the array dictionary to perform misspelling checking. E.g.
// your program will look like the following
#include <iostream>
#include <cstring>
...
#include "ex3.h" // ex3.h is provided by your instructor
int main()
{
...
// example of use of MAX_WORDS and dictionary
for (int i=0; i < MAX_WORDS; i++) {
... dictionary[i] ...
}
}
During debugging, you should create your own ex3.h to test your program.
In ex3.h, the constant MAX_WORDS specifies the number of strings contained within the array dictionary.
The array dictionary contains all the words you would use to check against the extracted words in the input text. If an input word cannot be found in dictionary, it should be considered a misspelled word.
The checking is case insensitive, e.g. "Twinkle" is equivalent to "twinkle"
As stated in the above section, misspelled words should then be enclosed by '#' in the output.
3. Important Points
1) You can assume that the maximum number of input lines is 100 and the maximum length of each line is
100 characters.
2) To input a line, you can use a statement like:
char buffer[200];
cin.getline(buffer, 200, '\n');
// buffer contains the input from the user, with the newline removed
3) The output should be a correct sequence of characters. You should NOT use a backspace to "erase" the
preceding character. For example, the following are NOT the same:
"abc<backspace><backspace>def" not the same as "adef"
|
|
|
|
|
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
|
|
|
|