You could redirect it to a text file, and then read the text file or examine pipes.
system("ping anipaddress > %TEMP%textfile.txt")
Then read the text file. thats the simpler option the better option would probably be pipes.
Chris
You could redirect it to a text file, and then read the text file or examine pipes.
system("ping anipaddress > %TEMP%textfile.txt")
Then read the text file. thats the simpler option the better option would probably be pipes.
Chris
*BUMP*
Come on guys i really need some help. :(
Short of writing a full code solution for you, we cannot provide alot more help.
Read the post and have an attempt.
Chris
std::cin >> ipadd;
commandArg = "ping " + ipadd.c_str();
system(commandArg);
Something along those lines should do you nicely. c_str() is in the string header btw.
Chris
lol, yer i should really go to sleep. At least someone pointed it out, thanks for spotting my silly mistakes.
Chris
2.What the heck does this mean?
"256 D:\game.cpp jump to case label "
"131 D:\game.cpp crosses initialization of `int randomm' "
You are trying to define a variable within a case statement of your switch. This doesn't work due to scoping laws. The quick and easy method to over come this is
switch(x){
case 1:
{
int b;
}
case 2:
Etc.
[1] Well use a while loop, with a bool flag, so something like this
bool continue = 1;
while(continue){
//blaahhhhhhhhhhhhhhh
if (quitVar == "yes") continue = 0;
}
And when you first enter the loop you should set the values for health etc there. So each time it go back to the start of the loop, before printing the menu it resets health etc.
Chris
The answer is most assuredly forty-two.
Well what else would it be, although i don't feel that this is important enought to be given an answer equivelant to the meaning of life!
but seriously, whats the question / problem?
Chris
for(int rando3=0; rando3<2; rando3++){
random4 = (rand()%10)+1;
if(rando3==1)
Look at this bit of code, you generate the random number and store it in random4 then in your if statement you check against rando3, which is the loop value, not the random number.
Chris
Just to mention, you don't have to declare char ptr, you can simply cast string:
(LPVOID)"HELLO";
But, if you want your string to work inside function that you call, you have to typecast it back to (char*)
Yes, im aware of both of these, it was just the mere fact i was paying way to much time listening to my god damn compiler / IDE and not enough looking at what i had actually written!
Thanks,
Chris
Ah that would make much more sense. i did wonder, thanks guys.
i feel like a fool now lol!
Chris
1.Still no answer why the rand doesn't work :S
2.And oh yeah, with the source code i posted,
whenever you have LESS than 0 money it tells you you don't have enough money.
How do i make it calculate for example:
You have 8 money and wanna buy something for 10 money = Not enough money.
It does work... just your not checking the random number! Your checking the loop inwhich you are generating a random number, so the loop counter always reaches 2 when it stops. So when you check what value it is, it's always going to be 2!
you should be checking the random number
Chris
OK, by no means is this safe. It was a meer test to get me started with threads.
#include <windows.h>
#include <iostream>
DWORD WINAPI MyThreadFunction( LPVOID lpParam );
int main()
{
DWORD dwThreadId;
HANDLE myThread;
myThread = CreateThread(
NULL,
0,
MyThreadFunction,
"HELLO",
0,
&dwThreadId);
while(1){
Sleep(3);
std::cout << "main";
}
std::cin.get();
return 0;
}
DWORD WINAPI MyThreadFunction( LPVOID lpParam )
{
std::cout << lpParam;
while(1){
Sleep(10);
std::cout << "thread";
}
return 0;
}
exact error: 17 invalid conversion from `const void*' to `void*'
Thanks
Hi, i'm havnig problem with calling CreateThread. The problem is that it gives me a conversion error from const void* to void*
DWORD dwThreadId;
HANDLE myThread;
myThread = CreateThread(
NULL,
0,
MyThreadFunction,
"HELLO",
0,
&dwThreadId);
dwThreadId id is the problem, the function is supose to take a pointer to a DWORD.
Thanks for any help
Cgris
im not gonna comment on errors in your code, since this may just be purposefull...
#include <ctime>
srand( (unsigned) time(NULL) );
randomnumber = rand() % 3 + 1;
that should give you a random number between 1 & 3.
Chris
That looks right to me, next state it to convert that into code, be it C++ or psuedo.
do each point indervidually, don't try and mix them up.
Chris
You need to seed the random number generator to make it generate a true random number. Try
#include <ctime> .... srand((unsigned)time(0));
As for not having enought money you may want to try putting "break" statements at the end of your switch cases... but I forget
He already does seed it, at a quick glance i would make a suggestion of changing your functions to save lots of calls to the function example
void merliv(int x)// more life
{
liv += x;
}
That way all you have to make is one call and you can increase it by however many you want, aslong as it is within the size of an int ofcourse. Which it would be.
Also you may want to look at class inheritance.
Chris
Not to sure what your actualy problem is but you are assigning X to [0][0] where X is a char that doesn't have a value and is not initialised. So you assign some random value from your memory into the array. NOT GOOD.
Chris
Create a new project add all the files to the project, then assuming the code is correct since we don't know it should work fine.
Chris
guys iam still new
alright dont warry next time i will follow the stracturesNOW are you going to help me or just add some Comments
Next time is good but what about this time, If you take into consideration what we said then we can help you. Until then we are pretty much just taking radom stabs in the dark.
Chris
Your going into searching and sorting algoithms. If the numbers are in ascending order then you can perform a bnary search which optimizes speed for finding the number. If is is not sorted into order then you must perform a sor of some kinf such as a quick sort. check these out on wikipedia
i can provide more detail if needed
Nevermind i read the question wrong
Chris
U should start with Socket programing;
reffer to book "beejs guide to network programing "
u can do it with in 3 days
I would question what, i think he may have problems installing a compiler on his pc let alone managing to write a simple hello world application, since he seem's to struggle with clicking and read.
Although he doesn't seem to have a problem with java, perhaps i missed something here!
Chris
First Google link would you believe it when i typed, Dev-Cpp
Learn to use your favorite search engine, its a very good tool when learning to program
Chris
To build on what Sci@phy siad, narrow it down to a small section of code aswell. Don't expect us to read all of that when we may only need to look at 5 lines of it!
Chris
if you ask me, Dev-Cpp. Used from the start til not long after the start (aka now lol). Nah Dev has stood me in good sted and never let me down
Chris
From the code i originally posted, all you had to do was update the loop to how sci@phy pointed out.
Then understand it....
How well do you know the language, i'm guessing not too well.
What kind of game do you want to make. A full blown first person shooter? or a guess the number game?
Either way more input would be helpful aslong as sample code.
Chris
ah thanks for pointing that out, i was forgetting there are characters that can cause eof to return true!
Chris
use a switch statement, then call the function you are after.
switch(b){
case 1:
menu1();
break;
case 2:
menu2();
break;
case 3:
menu3();
break;
default:
std::cout << "Invalid Choice!";
break;
}
I think that is what you are after,
Chris
No, there is not standard C++ method of doing this, or at least not that im aware of. If your using linux i believe the ncurses or pdcurses headers may have something to heklp you out. If your on windows then you can use windows.h
ReadConsoleOutputCharacter(
__in HANDLE hConsoleOutput,
__out LPTSTR lpCharacter,
__in DWORD nLength,
__in COORD dwReadCoord,
__out LPDWORD lpNumberOfCharsRead
);
#include <iostream>
#include <windows.h>
int main(void){
HANDLE hOut;
COORD location = {3, 5};
char letter;
DWORD numberRead;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
ReadConsoleOutputCharacter(hOut, &letter, 1, location, &numberRead);
std::cout << letter;
std::cin.get();
return 0;
}
Hope that helps, note untested.
Chris
The file will be read line by line. So the first line would be stored in the first variable. Ofcourse, if you want to make it possible to loop throught the file until all the variables are read in then your best bet would be to use and array (not stricktly true, vectors would be better but don't worry about those yet).
so create an array of doubles then loop throught the file storing each line into the next cell in the array.
i would do something like this
#include <iostream>
#include <string>
#include <cstdlib>
#include <ifstream>
int main(void){
char myFileName[64];
string line;
double numbers[100] = {0};
int x = 0;
ifstream locationtemp;
cout << "Enter the file name.\n";
cin >> myFileName;
locationtemp.open(myFileName);
if ( !locationtemp.good() ){
cerr << "\n\nERROR:Unable to open file/File did not open correctly\n";
cin.get();
return(1);
}
while( !locationtemp.eof() ){
getline(locationtemp, line);
numbers[x++] = strtod(line);
}
locationtemp.close();
return 0;
}
Something along those lines. Untested i don't have access to compilers in college
Chris
You should have a read about functions and parameters.
#include <iostream>
int Plus(int x, int y){
return x + y;
}
int main(){
int number;
int number2;
char op;
std::cout << "type in a number" << std::endl;
std::cin >> number;
std::cout << "another number" << std::endl;
std::cin >> number2;
std::cout << "+, - , * or /?" << std::endl;
std::cin >> op;
if(op == '+'){
std::cout << Plus(number, number2) << std::endl;
}
system("pause");
return 0;
}
I should point out you cannot read a '+' sign into an int, hence why i changed it to a char. Also you cannot use 'do' as a variable name as it is a command used in do..while loops.
Chris
edit:: damn 4 posts at once!
indeed, you must use the cmath header...
pow() and also sqrt() will find the square root of a number xD
pow takes to aruments first is the number to be raised to the powerof the second number if that makes sense.
Also i should talk about the chain rule.
the chain rule can be used to find the derivative of (ax+b)^z in a few simple steps.
It also applies to finding the derivative of e^(x-3x^2) in your case
the chain rule is this
dy/dx = du/dx * dy/du
now where does you come into well we set the power of e = u so
e^(x-3x^2) becomes
u = x-3x^2
therefore, we get this
f(x) = e^u therefore dy/du = e^u.
but we must find the derivative of u
u = x-3x^2
du/dx = x-6x
so back to the chain rule.
dy/dx = du/dx * dy/du
dy/dx = (x-6x) * (e^u)
dy/dx = (x-6x)(e^(x-3x^2))
Hope that helps you with finding the correct derivative.
Chris
Wrong it does, pick a number >= 60 it will work fine. mpm is an integer, integer's ignore and decimal places, so and number small that 60 when divided by 60 would make mpm equal to 0, thus 0*2 = 0, so the program continues to loop multiplying 0 by 2 until it reaches a number greater than one, which it won't.
Chris
Not my first or second choice. atoi() falls short at error handling.
strtol() is a better alternative.
That is too true, i'm glad you pointed that out. strtol() may prove helpful to me thanks.
Chris
Just had a quick look but something im gonna point out.
else if ((a >= 4) && (a < 5))
{
romanF[i] = 'I';
romanF[i+1] = 'V';
a = a-4;
i += 2;
}
could become
else if (a==4)
{
romanF[i++] = 'I';
romanF[i++] = 'V';
a -= 4;
}
This has made it cleaner, but also it has reduded the time complexity by only having to perform 1 comparison.
Chris
If you are looking to convert strings and into integers, you may want to check out the atoi() function.
Chris
strtok() would help. read some online documentation on it.
It splits a string based on a delimiantor
such as a pipe, this would allow you to retrieve all the different ssctions between the pipes. Then you could further process the {} out of the data.
Chris
Trying looking at how notepad is called from the registry command when you open a file, that tells you what to do for your application, if you apply some common sense.
> will the first argument be the file name from which the program has been called?
Yes.
I have a feeling you may get mixed up here, the FIRST would be argv[0]
which ofcourse is the name of the application, once you set your registry then argv[1]
will be equal to the text file that called it.
Chris
Btw, atoi() will convert it to a number, this may prove helpful for you to multiply your numbers. It will also convert it back to a char from a number.
Chris
you need to use getline() in that case to allows you to read more than just 1 character in at a time
Chris
More information would be nice but im kinda guessing it a mere spelling error should it be
double a=(h[0]*h[1])+......
Thats all i can guess from what you provided
Chris
As in the favorites tab?
Start-->Settings-->Taskbar & Settings.
It's then the second tab along i believe that should allow you to restore your favorites Tab.
Chris
The simple solution may just be re-install IE im guessing its IE7, should fix it
Chris
If you set the bios to boot from CD, then the only time i've ever seen this happen before is when the Disc was screwed..
Sorry i cannot provide any other solution, even after reading a bit more into this that still seems to be the only solution.
You could try downloading a free linux distro such as freBSD and burning that to a disc then see if that will install.
There is also this idea which is a bios reset.
When you get the f1 f2 screen do this
1) Caps lock light is on
2) Num lock ligh is on
3) scroll lock light is on
thats all 3 on then press
1) (ALT TAB) E
2) (ALT TAB) F
3) (ALT TAB) B
That should make you pc reboot automatically and you should be fixed fingers crossed
If you are getting 2 beeps it seems that may indicate a DDRAM problem.
Chris
Your asking for a full code solution to your assignment? I think you may be going wrong there
Chris
Have a look at partioning software such as partition magic. This should run fine from boot of a floppy disk and allow you to delete all partition on the computer leaving it blank ready for OS installation. Providing the bios isn't screwed and will allow for boot from cd
Chris
Hey guys, i recently installed Xubuntu 8.04 on my pc. And have been having issues getting my Belking wireless adaptor to work.
I followed an online guide and it now appears that my wireless adaptor is being recognised. However i am unable to "find" and connect to my netowrk... im guessing i have to configure it somehow only im stuck on that.
Thanks,
Chris
I'm not sure if i understood you but i think you are after something like this, windows only all i could find
ok List all the include directories from Dev-Cpp and we can compare to what they should be
We could spend all day trying to get you to re-build all of the incorrect includes etc on Dev or you could just reinstall it, since my guess is, ALL of the include directories etc are out. A re-install would take no time at all and would solve it all.
Chris