here is part of my code
extern "C" {
#include "hid.h"
#include "hidsdi.h"
#include "process.h"
#include %26lt;setupapi.h%26gt;
#include %26lt;initguid.h%26gt;
}
this is the error i get during compile:
|| Cannot open include file: 'hid.h': No such file or directory ||
i already have windows DDK installed.. how do i solve this problem?? do i add the directory of the headers file?? or add the library of the hid files to the linker??
Visual C++ Express 2008 progamming to include hid.h and hidsdi.h?
have you setup include directories and lib files in vc++?? if not here is a link that teaches you how to setup vc++ express edition 2005.. i hope setting up 2008 is also similar. Also Remove the inverted commas and use angular brackets because inverted comma limits the searching of files within one particular path...you have to add the path of the hid.h file to the include path list in tools-%26gt;options-%26gt;(on the left pane) projects and solutions-%26gt;vc++directories-%26gt;(on the right pane show directories for include files)-%26gt; and add the folder in which hid.h is present...
Sunday, August 2, 2009
Can any1 give me standard procedure for calling java method from "c++" using vc++?
basically it invovles invoking JVM....
i tried but got errors !
i tried as follows =%26gt;
created .java ,.class,.h files using javac,javah cmds.
opened vc++ =%26gt; win32 appl'n %26gt; c++ file as source
program is @ sun site JNI specification book ! invocation api's chapter...simple hello world program...
then i set paths of library at file jvm.lib.
set the preprocessor path to jni.h means C:\j2sdk1.4.2_05\include
and run ....
gives many errors linking error like
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/ltry.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
ltry.exe - 2 error(s), 0 warning(s)
sometimes gives error C:\ltry\tr.cpp(18) : warning C4129: 'j' : unrecognized character escape sequence
in code @
options[0].optionString="-Djava.class....
can any1 tell me valid procedure ?
do u hav anyother gud book for invocation api's?
Thanks Amit
Can any1 give me standard procedure for calling java method from "c++" using vc++?
I dont know what the probelm is but it does work when i refer
the docs.
But the procedure will br something like
1. Create a JVM Instance
2. Create an object of the Java Class
3. Call the Method.
The Names will be something like
Java_ClassName_MethodName( Para List );
i tried but got errors !
i tried as follows =%26gt;
created .java ,.class,.h files using javac,javah cmds.
opened vc++ =%26gt; win32 appl'n %26gt; c++ file as source
program is @ sun site JNI specification book ! invocation api's chapter...simple hello world program...
then i set paths of library at file jvm.lib.
set the preprocessor path to jni.h means C:\j2sdk1.4.2_05\include
and run ....
gives many errors linking error like
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/ltry.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
ltry.exe - 2 error(s), 0 warning(s)
sometimes gives error C:\ltry\tr.cpp(18) : warning C4129: 'j' : unrecognized character escape sequence
in code @
options[0].optionString="-Djava.class....
can any1 tell me valid procedure ?
do u hav anyother gud book for invocation api's?
Thanks Amit
Can any1 give me standard procedure for calling java method from "c++" using vc++?
I dont know what the probelm is but it does work when i refer
the docs.
But the procedure will br something like
1. Create a JVM Instance
2. Create an object of the Java Class
3. Call the Method.
The Names will be something like
Java_ClassName_MethodName( Para List );
C++ Programming HELP?
I have no idea of where to start on this assignment:
Write a program that displays all the prime numbers between 50 and 100.
A prime number divides only in 1 and in itself.
Note: You can make it more efficient by checking the divisors of N from 2 and upto
square root(N), instead of (N)).
There is a library function called sqrt(n) which is included in the %26lt;math.h%26gt; header file.
sqrt(n) returns the square root of n.
File name: prime.c
please help me, totally lost here
C++ Programming HELP?
wow that's a tuffie
Reply:seems easy try this.
start checking every number to see wether it is prime or not!(you need a for struct)
for checking if a number is prime or not you need for that checks (your number)mod (another number from 2 to sqrt(your number))
if it is 0 you will write count++
and at the end if count is=0 print the number!
if it needs more explanation let me know
Reply:for(int i = 50; i %26lt; 101; i++)
{
for(int j = 0; j %26lt; Math.sqrt(i); j++)
{
if(i/j != 0)
{
printf("%d", i);
}
}
}
at least that's the general idea...
Reply:#include %26lt;iostream%26gt;
using namespace std;
void main()
{
cout%26lt;%26lt; "53 59 61 67 71 73 79 83 89 97 " %26lt;%26lt; endl;
}
Reply:OK. Let n be the number you're testing to see if it's a prime. This will start at 50 and increase to 100.
Function to test if n is a prime:
Let f be some number that you think may be a factor of n (start with f = 2), and let g = 1.
If (n % f) == 0, then n is a multiple of f and therefore not prime, so return false.
Otherwise: let f += g.
If f == 3 then let g = 2.
If f %26gt; 5 then let g = 6 - g.
If f * f %26gt; n, then f is bigger than the square root of n, meaning n must be prime so return true. Otherwise, test (n % f) again.
Note: you don't actually need to evaluate the square root at all. Doing an integer multiplication on each iteration is still quicker, on average, than evaluating a square root once! This is because most numbers are not prime, so you will usually drop out of the loop before doing this multiplication too many times. The reason for alternately adding 2 or 4 (which is what g does) is so you skip over all odd multiples of 3, which are not prime and so needn't be tested as potential factors (since their factors have already been tested). So the sequence goes 2 (miss 1) 3 (miss 2) 5 (miss 2) 7 (miss 4) 11 (miss 2) 13 (miss 4) 17 %26amp;c.
Note also: You could do the "alternately adding either 2 or 4" thing with n, and it would be a little more efficient since you are eliminating all multiples of 2 and 3 (though these will get rejected in 1 or 2 iterations anyway). But 50 doesn't fit this sequence, and starting with 53 would be cheating.
song downloads
Write a program that displays all the prime numbers between 50 and 100.
A prime number divides only in 1 and in itself.
Note: You can make it more efficient by checking the divisors of N from 2 and upto
square root(N), instead of (N)).
There is a library function called sqrt(n) which is included in the %26lt;math.h%26gt; header file.
sqrt(n) returns the square root of n.
File name: prime.c
please help me, totally lost here
C++ Programming HELP?
wow that's a tuffie
Reply:seems easy try this.
start checking every number to see wether it is prime or not!(you need a for struct)
for checking if a number is prime or not you need for that checks (your number)mod (another number from 2 to sqrt(your number))
if it is 0 you will write count++
and at the end if count is=0 print the number!
if it needs more explanation let me know
Reply:for(int i = 50; i %26lt; 101; i++)
{
for(int j = 0; j %26lt; Math.sqrt(i); j++)
{
if(i/j != 0)
{
printf("%d", i);
}
}
}
at least that's the general idea...
Reply:#include %26lt;iostream%26gt;
using namespace std;
void main()
{
cout%26lt;%26lt; "53 59 61 67 71 73 79 83 89 97 " %26lt;%26lt; endl;
}
Reply:OK. Let n be the number you're testing to see if it's a prime. This will start at 50 and increase to 100.
Function to test if n is a prime:
Let f be some number that you think may be a factor of n (start with f = 2), and let g = 1.
If (n % f) == 0, then n is a multiple of f and therefore not prime, so return false.
Otherwise: let f += g.
If f == 3 then let g = 2.
If f %26gt; 5 then let g = 6 - g.
If f * f %26gt; n, then f is bigger than the square root of n, meaning n must be prime so return true. Otherwise, test (n % f) again.
Note: you don't actually need to evaluate the square root at all. Doing an integer multiplication on each iteration is still quicker, on average, than evaluating a square root once! This is because most numbers are not prime, so you will usually drop out of the loop before doing this multiplication too many times. The reason for alternately adding 2 or 4 (which is what g does) is so you skip over all odd multiples of 3, which are not prime and so needn't be tested as potential factors (since their factors have already been tested). So the sequence goes 2 (miss 1) 3 (miss 2) 5 (miss 2) 7 (miss 4) 11 (miss 2) 13 (miss 4) 17 %26amp;c.
Note also: You could do the "alternately adding either 2 or 4" thing with n, and it would be a little more efficient since you are eliminating all multiples of 2 and 3 (though these will get rejected in 1 or 2 iterations anyway). But 50 doesn't fit this sequence, and starting with 53 would be cheating.
song downloads
Using exponent in C++ Visual Basic 2005 Express Edition?
Pretty straightforward, how can you use exponents in C++ visual Basic 2005 Express edition. The internet has conspired against me, and the textbooks we are using are for a outdated C++ version. It would be most appreciated for someone to show me how to do a simple function such as (3.0 * 10^8) and show me which library to use.
Using exponent in C++ Visual Basic 2005 Express Edition?
//
// Done in Visual C++ 2005Express Edition
//
#include %26lt;iostream%26gt;
#include %26lt;math.h%26gt;
void main()
{
double val = 0.0;
val = 3.0 * pow(10.0, 8.0);
std::cout %26lt;%26lt; "3.0 * 10^8 = " %26lt;%26lt; val %26lt;%26lt; "\n";
val = pow(3.0, 8.0);
std::cout %26lt;%26lt; "3.0 ^ 8.0 = " %26lt;%26lt; val %26lt;%26lt; "\n";
}
///// --- output --- ////
3.0 * 10^8 = 3e+008
3.0 ^ 8.0 = 6561
Using exponent in C++ Visual Basic 2005 Express Edition?
//
// Done in Visual C++ 2005Express Edition
//
#include %26lt;iostream%26gt;
#include %26lt;math.h%26gt;
void main()
{
double val = 0.0;
val = 3.0 * pow(10.0, 8.0);
std::cout %26lt;%26lt; "3.0 * 10^8 = " %26lt;%26lt; val %26lt;%26lt; "\n";
val = pow(3.0, 8.0);
std::cout %26lt;%26lt; "3.0 ^ 8.0 = " %26lt;%26lt; val %26lt;%26lt; "\n";
}
///// --- output --- ////
3.0 * 10^8 = 3e+008
3.0 ^ 8.0 = 6561
Need help in C language?
how to convert a char to other case in C language.
for eg. char letter='a'
then output should be A.
the problem is, it has to be done using bitwise operators.
i suppose not to use any standard library functions.
its an exercise given in "art of assembly" chapter 1 (p-63 1st problem)
for eg. ascii of a is 65 and that of A is 97
and in binary 65(A) is 0100 0001
whereas ...... 97(a) is 0110 0001
notice the sixth bit from right.
It decides the case of the letter.
I hope, NOT logic operation on this bit could change its case.
Adding 32 (0010 0000) or 20h does some work in converting.
it converts upper case to lower case.
eg. 0100 0001(A) + 0010 0000 (32)= 0110 0001(a)
But i dont know how to do so in C language.
Please help.
also help me by explaining the operators used in C to manipulate bits.
Need help in C language?
You can use the XOR (exclusive or) bitwise operator to flip the 6th bit. That will convert 'a' to 'A' and back again:
0100 0001 XOR 0010 0000 = 0110 0001
0110 0001 XOR 0010 0000 = 0100 0001
or, in decimal:
65 XOR 32 = 97
97 XOR 32 = 65
The C bitwise operator for XOR is the caret: ^
65^32 will give you 95.
97^32 will give you 65.
Reply:Hi,
Firstly you need to select only the lower case letter so we assume you can do a sample check as in
if (letter %26gt;= 'a' %26amp;%26amp; letter %26lt;= 'z')
and if it is then bitwise and as in
letter %26amp;= 0xDF
or
newletter = letter %26amp; 0xDF
Hope this helps.
Reply:I don't know C specifically, but if it's anything like C++, create a char variable, initialize it as 'a', and add 32... You can manipulate and compare chars and strings mathimatically, because that's basically how their stored
Reply:If your char is called cAlpha you would do this -
cAlpha = cAlpha %26amp; 0xdf;
or -
cAlpha %26amp;= 0xdf;
or what I tend to use -
cAlpha %26amp;= ~0x20;
This is the bitwise AND operator. It always clears bits to that are zero in its argument. The argument is often refered to as being a mask. 0xdf is '1101 1111' in binary. The sixth bit is zero the rest are set, the sixth bit of your value will be cleared, the rest will be left as they are.
In the third example I use the bitwise NOT operator '~' to create the mask. This swaps every bit in the value. In this case 0x20 (0010 0000) becomes 0xdf (1101 1111). I do this because its often easier to understand code if it shows the value that is being cleared rather than its mask.
The OR operator '|' always sets bits to one.
The XOR operator '^' swaps bits.
In the case of alpha characters you have to be careful. 'a' is 97 'z' is 122, they don't cover the entire range of number range of that bit. If you always applied the mask you will change all the chars between 96 and 127, 160 and 191, 224 and 255.
You need a piece of code that says -
if (cAlpha %26gt;= 'a' %26amp;%26amp; cAlpha %26lt;= 'z')
before the bit twiddling. Note that's a logical AND operation in the if statement.
for eg. char letter='a'
then output should be A.
the problem is, it has to be done using bitwise operators.
i suppose not to use any standard library functions.
its an exercise given in "art of assembly" chapter 1 (p-63 1st problem)
for eg. ascii of a is 65 and that of A is 97
and in binary 65(A) is 0100 0001
whereas ...... 97(a) is 0110 0001
notice the sixth bit from right.
It decides the case of the letter.
I hope, NOT logic operation on this bit could change its case.
Adding 32 (0010 0000) or 20h does some work in converting.
it converts upper case to lower case.
eg. 0100 0001(A) + 0010 0000 (32)= 0110 0001(a)
But i dont know how to do so in C language.
Please help.
also help me by explaining the operators used in C to manipulate bits.
Need help in C language?
You can use the XOR (exclusive or) bitwise operator to flip the 6th bit. That will convert 'a' to 'A' and back again:
0100 0001 XOR 0010 0000 = 0110 0001
0110 0001 XOR 0010 0000 = 0100 0001
or, in decimal:
65 XOR 32 = 97
97 XOR 32 = 65
The C bitwise operator for XOR is the caret: ^
65^32 will give you 95.
97^32 will give you 65.
Reply:Hi,
Firstly you need to select only the lower case letter so we assume you can do a sample check as in
if (letter %26gt;= 'a' %26amp;%26amp; letter %26lt;= 'z')
and if it is then bitwise and as in
letter %26amp;= 0xDF
or
newletter = letter %26amp; 0xDF
Hope this helps.
Reply:I don't know C specifically, but if it's anything like C++, create a char variable, initialize it as 'a', and add 32... You can manipulate and compare chars and strings mathimatically, because that's basically how their stored
Reply:If your char is called cAlpha you would do this -
cAlpha = cAlpha %26amp; 0xdf;
or -
cAlpha %26amp;= 0xdf;
or what I tend to use -
cAlpha %26amp;= ~0x20;
This is the bitwise AND operator. It always clears bits to that are zero in its argument. The argument is often refered to as being a mask. 0xdf is '1101 1111' in binary. The sixth bit is zero the rest are set, the sixth bit of your value will be cleared, the rest will be left as they are.
In the third example I use the bitwise NOT operator '~' to create the mask. This swaps every bit in the value. In this case 0x20 (0010 0000) becomes 0xdf (1101 1111). I do this because its often easier to understand code if it shows the value that is being cleared rather than its mask.
The OR operator '|' always sets bits to one.
The XOR operator '^' swaps bits.
In the case of alpha characters you have to be careful. 'a' is 97 'z' is 122, they don't cover the entire range of number range of that bit. If you always applied the mask you will change all the chars between 96 and 127, 160 and 191, 224 and 255.
You need a piece of code that says -
if (cAlpha %26gt;= 'a' %26amp;%26amp; cAlpha %26lt;= 'z')
before the bit twiddling. Note that's a logical AND operation in the if statement.
C++ Graphics placment question?
The text's graphics library places the origin of its coordinate system in what position by default?
a) center of the screen
b) lower left hand corner of screen
c) upper left hand corner of screen
d) lower right hand corner of the screen
AND it's NOT 'C' (I made sure)
C++ Graphics placment question?
I would say the center of the screen - A.
The other answers sounds bogus (except for C).
Reply:C++ doesn't know anything about graphics, however various graphics libraries do provide those capabilities. Since you neglected to tell us what libraries you are using no help can be provided.
a) center of the screen
b) lower left hand corner of screen
c) upper left hand corner of screen
d) lower right hand corner of the screen
AND it's NOT 'C' (I made sure)
C++ Graphics placment question?
I would say the center of the screen - A.
The other answers sounds bogus (except for C).
Reply:C++ doesn't know anything about graphics, however various graphics libraries do provide those capabilities. Since you neglected to tell us what libraries you are using no help can be provided.
[C++] Firewall Tutorial?
Okay, So basically in C++ i want to create a kind of firewall. I want my firewall to be able forward ports or block them. How in C++ would I create a firewall for Windows. That can either block a port or forward a port to a certain IP Address. What library would I use? (Already searched Google, found a bit but nothing good) Any good resources (Books or web)? And any other information you got?
Daniel
[C++] Firewall Tutorial?
http://www.codeproject.com/managedcpp/po...
http://www.symbian.com/developer/techlib...
Like yahoo answers but for programmers. Might be worth checking out:
http://www.thescripts.com/forum/register...
sending flowers
Daniel
[C++] Firewall Tutorial?
http://www.codeproject.com/managedcpp/po...
http://www.symbian.com/developer/techlib...
Like yahoo answers but for programmers. Might be worth checking out:
http://www.thescripts.com/forum/register...
sending flowers
Subscribe to:
Posts (Atom)