|
|
I'm currently working on a program that outputs the information given under ipconfig/all in DOS to a text file. Now even though this seems very simple do check normally, its for people who don't know dos commands and that sort of thing. However to make this program more effective I would like to have it output the Public IP address of a network, this can be done normally by visiting http://whatismyip.com
The code is currently:
#include <windows.h>
#include <winable.h>
#include <iostream>
int main()
{
system("ipconfig/all >> \"C:\\Documents and Settings\\gamefreak\\desktop\\test.txt\"");
}
which is working, now I'm trying to output the information provided by http://www.whatismyip.com/automation/n09230945.asp
I suppose an answer on how to copy and paste all the information from a webpage in C++ would work the easiest.
|
|
|
|
|
Have you tried InternetReadFile() ? I just tried and it seemed to work fine.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
No I have not tried InternetReadFile(), I looked into to it and I can't seem to get it to work..
I'm not very good when it comes to Win API functions
|
|
|
|
|
i have this problem, i am an amateur in programming c++ so i made this simple program: i have d0, d1, d2, and d3, i give them some values, then i have a, b, c, d, e, f, and g, and i want to calculate them with a math operation for each one, but that operation uses the d0, d1, d2, d3 values that you gave them before with the cin's, so, after you give the values to d0, d1, d2, and d3, the program closes itself because it finishes doing everything but i cant see the results for the a, b, c, d, e, f, and g operations. Can someone help me please.
This is my code:
#include <cstdlib>
#include <iostream>
#include <stdio.h>
using namespace std;
main()
{
int d0, d1, d2, d3;
int a, b, c, d, e, f, g;
//Meto los valores 0 y 1 de las variables d0, d1, d2, d3
cout<< "Inserte los valores de las siguientes variables:\n"<<endl;
cout<< "Variables: d0, d1, d2, d3\n";
cout<< "TIENEN QUE SER 0 o 1\n";
cout<< "Inserte d0\n";
cin>> d0;
cout<< "Inserte d1\n";
cin>> d1;
cout<< "Inserte d2\n";
cin>> d2;
cout<< "Inserte d3\n";
cin>> d3;
cout<< "Ahora se muestran los valores de cada segmento\n";
//Calculo los valores de las variables a, b, c, d, e, f, g, utilizando los valores de d0, d1, d2, d3
a= ((d0&&d2)||(!d0&&!d2)||(d1)||(d3));
b= ((d0&&d1)||(!d0&&!d1)||(!d2)||(d3));
c= ((d0)||(!d1)||(d2)||(d3));
d= ((!d0&&!d2)||(!d0&&d1)||(!d0&&d3)||(d1&&!d2)||(d1&&d3)||(d0&&!d1&&d2));
e= ((!d0&&d1)||(!d0&&d2));
f= ((d0&&d2)||(d0&d1)||(d2&&d2)||(d3));
g= ((!d0&&d1)||(!d1&&d2)||(!d1&&d2)||(d3));
//Muestro los valores en pantalla
cout<< a <<"\n";
cout<< b <<"\n";
cout<< c <<"\n";
cout<< d <<"\n";
cout<< e <<"\n";
cout<< f <<"\n";
cout<< g <<"\n";
}
|
|
|
|
|
just before the last bracket in the program, add system("PAUSE") . This will only work if you're using Windows or DOS.
|
|
|
|
|
I don't understand but only a few words of the Spanish and I was too lazy to check the math because I don't understand it either..(think I need to know the comment right before it)
Anyhow if you add getch(); or system("pause"); right before your final bracket that will fix the problem for you.
*notes: system("pause") should be platform dependent, but works in windows.. you have to press the enter key before the program does anything else
getch = get character, all it does it waits for any key at all to be pressed and then continues.. should work on any platform but you may accidently hit a key and close the program
its common practice to include return 0; or return 1; but as you can see, not necessary .
|
|
|
|
|
looks like you and i are on the same page. glad we're quick on the keyboard
|
|
|
|
|
by the way, a suggestion: make the main() function return an int; i.e., int main() . and add return 0 to the end of the code. it's good practice.
|
|
|
|
|
Yeah I suggested the return 0 part but i failed to notice he didn't make main() an int or I would of mentioned that part too
|
|
|
|
|
I have created an SDI app with view/document architecture. Reviewing many books on this concept, I understanding there is linkage with pointers between the following:
1) Application Object to Document Template
2) Document Template to Document Object
3) Document Template to FrameWindow
4) Document Object to View Object
5) View Object to Document Object
5) Frame Window to View Object
Yes, nice concepts but how do I use these pointer, no good "real examples".
4 books later and I am still ripping my hair out. Can someone show some code snippets on how I would initialize the pointers and use these pointers.
For example in my app I have some data coming from a comm port, using a 3rd party C++ lib, a function is called when a new comm msg arrived. I would like to store this data in the Document object which would then call a Document Object method that would execute CDocument::UpdateAllViews to notify the View to get the new data from the CDocument object and update the displayed screen. How can I directly call a CDocument method that I add to my project, i.e from the function that is called with the new comm msg arrives ? My other thought is to post a message to the CDocument object which would trigger the view updating. I understand the concept of this view/document architecture just need some help in "real code" snippets. If I could just get past this concept.
|
|
|
|
|
Hi,
I'm using Embedded Visual C++ 4.0 for this project so it's a little different than the recent versions of VC++ but by and large it's the same interface, albeit more similar to the older Visual Studio 6.0 from years past.
So the problem is this:
I have a large project that consists of several smaller projects. One of these smaller projects, a lib project, keeps fully recompiling every darned time I compile the project, even though no changes have been made to it. The other lib files are fine, they don't recompile unless I change one of their cpp/h files. I'm sure it's just some silly setting on this lib project but for the life of me I can't find it. Does anyone know what I can do to stop it from recompiling every time?
Thanks!
KR
|
|
|
|
|
Is there some way of showing a verbose listing of what the build system's doing? It might tell you what file(s) it's looking for that's causing the rebuild?
Alternatively (and this is something I've done with VS2003/8), you could use SysInternals ProcMon to see what files the build system (msdev for eVC++4?) is accessing - you may well see it looking for files that a) don't exist, and b) aren't built by the build command for some reason.
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Oops, sorry I forgot to respond to this but I did actually fix it, the project that kept recompiling was looking for files from a project that weren't added into my parent project. I guess somehow since the one sub-project wasn't added into the parent, the files weren't registering as having been compiled "under the project" or something. When I added in the dependant project, everything was fixed.
KR
|
|
|
|
|
Check the dates on the lib-project source files. If (for some reason) they're in the future, the compiler will think the object and lib files are always out of date.
I've seen a similar problem when the computer's system date is in the past. The new object and lib files get this old date, so always appear out of date.
If the lib project uses a DLL with a future date, this can give the same symptoms.
Another guess: The dependencies may not be set up correctly for this lib project.
|
|
|
|
|
|
Good luck (with your homework).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Probably your teacher could...but he's asking you to provide them to him!!!!
Do your own homework, sunshine! You have so many resources (Google, CP, the web!) that make it easier.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
vidya556 wrote: could anyone please provide me the correct answers?
I don't see any questions.
|
|
|
|
|
|
vidya556 wrote: i had attended an interview so i was asked this but i couldn't understand
Really? You've applied for a job as a C++ programmer (presumably) and you don't know about memory management?
All of those questions are pretty basic, and even if you didn't go into a lot of detail, you should have been able to show a basic understanding of the subject.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
I am from a mechanical background and fresher so had told him whtever i had know abt the new and delte but he was not satisfied wid the answer.
So is the reason i am asking u guys wid lot of experience to give me the perfect answer for all the above question.
If u find it pretty simple y don't u share the knowledge.
|
|
|
|
|
If you're a fresher, then I'd guess he wanted to judge your level of knowledge for what he'll be teaching you in class. I wouldn't expect someone starting out in progrmming to know much about memory managers, or anything else really.
Anyway, the subject s quite complex, and would take several pages to explain all the details, particularly to the level asked for in your original post. There's really no way anyone can give you the information you need in a single short answer on this board. Your best approach, if you really want to learn this stuff, is to use Google, and read books on the subject.
Alternatively you could ask your tutor / lecturer if he expects you to know this, or if it's part of what he'll be teaching.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
There are rules[^] to post a query on this forum. Your query does not comply with those, so don't be surprised if you are not being helped.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|