William Hemsworth 1,339 Posting Virtuoso

Start by making a program that will at least compile, anything is better than nothing.

#include <iostream>

int main() {
   return 0;
}

Now, heres an example of how to convert a single variable to MPH using the formula given.

#include <iostream>

int main() {
   double KPH = 50;
   double MPH = KPH * (5.0 / 8.0);
   return 0;
}

And now that you can do that, try making an attempt at the rest by yourself. Although admitedly, I don't quite understand what you mean by "convert an array to MPH if data represents KPH"... is that an array of numbers you need to convert? or a string..? :icon_cheesygrin:

William Hemsworth 1,339 Posting Virtuoso

First of all, don't use void main, theres just no need, and main always returns int.
If I understood correctly, I think your teacher wants you to make a simple loop to display the characters 10-12, without cycling through the rest.

#include <iostream>
using namespace std;

int main() {
   char test[15] = {'T', 'h', 'i','s', '_', 'i', 's', '_', 'a', '_', 't', 'e', 's', 't'};
   int row;

   cout << "Characters 10-12 are:"<<endl;
   for (char row = 9; row < 13; row++) {
      cout << test[row];
   }
   cout << "\n" <<endl;
}

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

>Did not you learn that variables start with alphabets and _?
How did I not notice that :).. Well spotted.

William Hemsworth 1,339 Posting Virtuoso

Would you mind posting the entire code?..

William Hemsworth 1,339 Posting Virtuoso

Careful with http://www.penisland.net/, change it to .com, and you've got yourself a problem ;o

William Hemsworth 1,339 Posting Virtuoso

I assume the test fails to take consideration of age?..

William Hemsworth 1,339 Posting Virtuoso

For the first one, I got an IQ of 120 :)
Woo! I have "High Intelligence".. only 10 away from superior intelligence.

William Hemsworth 1,339 Posting Virtuoso

Haven't done .NET in a hell of a long time, but doesn't it go something like this?

[DllImport("DLLNAME.dll")]
static extern void FUNCTION_NAME(PARAMS);

May not be right, but I hope this helps.

William Hemsworth 1,339 Posting Virtuoso

be thankful :) , email subscriptions don't even work for me ;o

William Hemsworth 1,339 Posting Virtuoso

>Oops lol i added an extra 0.
Try taking off a couple more :)

>Soo, do you hack pokemon games?
Honestly.. No! >.<

Alex Edwards commented: XD +4
William Hemsworth 1,339 Posting Virtuoso

ehh? :|

>theres like over 200,000 people that do it.
Im curious how you got that figure..

Members: 87,951, Active Members: 14,949

William Hemsworth 1,339 Posting Virtuoso

>Do you hack pokemon games as well?
Thats not even worth a reply.. :icon_eek:

William Hemsworth 1,339 Posting Virtuoso

>and was wondering if anyone else does
I highly doubt it.

William Hemsworth 1,339 Posting Virtuoso

>I think you are having way too much fun with this
thats probably true ;) (just got 407)

William Hemsworth 1,339 Posting Virtuoso

Perhaps read the text from the text box into a string, and use std::stringstream to break it up.

William Hemsworth 1,339 Posting Virtuoso

Perhaps if you had read the rules and used code tags, I would be a little more encouraged to help.. Read This Before Posting

William Hemsworth 1,339 Posting Virtuoso

What annoys me more is the dumb Smily Central thing, every time I hover my mouse over it, I get the annoying disruptive "hellooooooo" sound..

William Hemsworth 1,339 Posting Virtuoso
William Hemsworth 1,339 Posting Virtuoso

I got 166 using only my right hand (I was eating rice with the other..), seems to me like The Dude is one hell of a slow typer :D
- Just got 392 using both hands, Woo! x]

William Hemsworth 1,339 Posting Virtuoso

238 first try, 265 second time, fun addictive little game xD

William Hemsworth 1,339 Posting Virtuoso

If you have to write your own square root function, I would recommend the Babylonian method.

William Hemsworth 1,339 Posting Virtuoso

100 Reasons why Evolution is so stupid
Some good points are mentioned in this (rather long) video, but no where near enough to stop me believing in evolution :icon_cheesygrin: but personally, I dont think he knows what hes talking about 95% of the time :)

William Hemsworth 1,339 Posting Virtuoso

You Are 35% British
You're about as British as a half hearted Anglophile... in other words, a piss poor Brit.
If you are indeed from Britain, you probably consider yourself a European more than anything else.

If you're trying to pass for a Brit, you're going to have to try a little harder.
Go to a football match. Drink until you puke. And head in to work the next morning totally hungover.

Sounds about right.

William Hemsworth 1,339 Posting Virtuoso

>Use the recovery disc.
Thats asuming he made one before the password changed.

I once had the same problem, this worked for me (took alot of searching).
http://pcsupport.about.com/od/toolsofthetrade/gr/pcloginnow.htm

William Hemsworth 1,339 Posting Virtuoso

Lardmeister, you have the book How to avoid a wombat's bum I guess :)

William Hemsworth 1,339 Posting Virtuoso

I woulden't consider myself a prodigy, I guess im just well motivated. :icon_cheesygrin:
A friend of mine showed me flash (AS2) when I was about 12, which got me quite interested x]
I then moved to C++ about 1-2 years ago which I have stuck to ever since. But I was interested in computers and eletronics way before I started coding.

William Hemsworth 1,339 Posting Virtuoso
William Hemsworth 1,339 Posting Virtuoso

Well, considering that im 15 years old and have been coding since about the age of 12, don't have a job and am free to do pretty much anything I want :D I code when I have nothing else to do (or feel like it), so I woulden't say it 'takes my life', I have many hobbies and would say its more of an addition to my life. :)

William Hemsworth 1,339 Posting Virtuoso

Born in Portugal, live in England.. :]

William Hemsworth 1,339 Posting Virtuoso

Trig isn't all that difficult.. I put together a small example of how to create a bitmap, draw a circle and a sector in it (with a 50 deg angle). I tried to keep the code as short as possible, but it is still over 200 lines, so I will post the important part and attach the whole code. It should draw on the bitmap and save it as circle.bmp in the project folder.

const double PI = 3.141592;
const double deg_to_rad = PI / 180;
const double rad_to_deg = 180 / PI;

void draw_sector(Bitmap &bmp, int deg_startangle, int deg_finangle, int radius) {
   int centre_x = bmp.width / 2;
   int centre_y = bmp.height / 2;

   // Start Angle
   bmp.line(
      centre_x, // x1
      centre_y, // y1
      int(centre_x + cos(deg_startangle * deg_to_rad) * radius), // x2
      int(centre_y + sin(deg_startangle * deg_to_rad) * radius) // y2
   );

   // Finish Angle
   bmp.line(
      centre_x, // x1
      centre_y, // y1
      int(centre_x + cos(deg_finangle * deg_to_rad) * radius), // x2
      int(centre_y + sin(deg_finangle * deg_to_rad) * radius) // y2
   );
}

int main() {
   // Create Bitmap object
   Bitmap bmp(500, 500);

   // Centre of bitmap
   int centre_x = bmp.width / 2;
   int centre_y = bmp.height / 2;

   // Radius of circle
   int radius = 150;

   int x1, y1, x2, y2; // Temp location variables

   // Set default old coordient
   x2 = centre_x + radius;
   y2 = centre_y;

   cout << "Drawing circle with a sector of 50 deg\n";

   // Draw a circle ( loop from 0 to …
Alex Edwards commented: Whoo! You're a genius kid XP +4
William Hemsworth 1,339 Posting Virtuoso

I managed to make the code compile free of errors and warnings, here are the changes I made.

#include<iostream>
#include<string>
#include<sstream>
#include<winsock2.h>
[B]#include<ws2tcpip.h>[/B]

[B]#pragma comment(lib, "Ws2_32.lib")[/B]

using namespace std;

struct addrinfo hints;      	//fill your host info - hints is input
struct addrinfo *results;	//gets your host info - results is output
char *remoteIP = new char[40];  //holds inserted remote IP
string tempPort;                //holds ports temporarly
int startingPort;               //stores the starting range of port number
int status;                     //receives the status of your pc address
int currentPort;           //holds current port


//program description
void progDesc()
{
     cout<<"This is a simple port scanner, scan range of\n";
     cout<<"ports on your local machine...\n"<<endl;

}


//getaddrinfe locates your machine, more specific
//details of your host address is returned to results.
void getAddrIn()
{
	status = getaddrinfo(remoteIP, NULL , &hints, &results);

	if(status != 0)
	{
		fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
		exit(1);
	}
}


//Run the program
int main()
{
	int endingPort;                 //stores the ending rage of port number

    WORD wVersionRequested;
    WSADATA wsaData;
    int err;

	/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
    wVersionRequested = MAKEWORD(2, 2);

    err = WSAStartup(wVersionRequested, &wsaData);
    if (err != 0) {
        /* Tell the user that we could not find a usable */
        /* Winsock DLL.                                  */
        printf("WSAStartup failed with error: %d\n", err);
        return 1;
    }

	system("[B]cls[/B]");

	//tell user what program does
	progDesc();

	//set size of hints to zero
	memset(&hints, 0, sizeof hints);

	//fill some of your host address info
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;

	//ask for remote IP
	cout<<"Please …
William Hemsworth 1,339 Posting Virtuoso

Whats with the sudden upsession of farts? :D ;)

William Hemsworth 1,339 Posting Virtuoso

That was just my example, if you code it yourself, you will probably be able to execute notepad before it opens.. remember my code was just an example of how to make an external program a child window within your window.

William Hemsworth 1,339 Posting Virtuoso

I've got a working program with a child window setup the way I want it, but now I want to make that child window an external program such as notepad. Any ideas?

Thats what my original code did.. :idea: try doing what I said, the notepad window my not be visible at first, but thats because of painting problems, try minimizing and restoring the window, then you should see it. Heres a couple of screenshots showing before compiling & running the program, and after.

William Hemsworth 1,339 Posting Virtuoso

i think you should try including
iostream too.

No need, theres no references to anything in iostream yet.

William Hemsworth 1,339 Posting Virtuoso

On line 47, you try to use the member BasicHandphone::smsStatus, which you commented out.. so by uncommenting it, you remove that error. You also fergot to add the prototype for the operator>> function, so change you class like this.

class BasicHandphone {
private:
 
   int f; 
   int smsStatus[10];
   int inboxCount;
   string sms[10];
   string smsDraft;

public:
   BasicHandphone()
   {int f = 0;}
   void draftMessage();
   void showInbox();
   void readMessage();
   [B]string operator >>(BasicHandphone & g);[/B]
   string operator + (BasicHandphone &);
};
William Hemsworth 1,339 Posting Virtuoso

Embedding is always done with OLE.

... care to explain why? :?:

William Hemsworth 1,339 Posting Virtuoso

This worked great for me.. http://69.10.233.10/KB/architecture/lint.aspx
Otherwise, your going to have to be abit more specific on what you want here.

William Hemsworth 1,339 Posting Virtuoso

Can you post some code where you are using the _tcscat_s function?

William Hemsworth 1,339 Posting Virtuoso

Code this small can easily be embedded into your post, so in future, do it :icon_wink:

#define _AFXDLL

#include <fstream>
#include <string>
#include <Cstringt.h>
#include <iostream>
#include <direct.h>
#include <afxv_w32.h>

using namespace std;

int main()
{
	string line1, line2 ; 
	string end_str ;
	CFileFind  finder;
	bool finding = finder.FindFile ();
	bool firstFile=1;
	bool condition;
//-------------------------------------------------------------	
	end_str = "<ENDFILE;" ;
	condition= 0;
	while (finding)
    {
	    finding = finder.FindNextFile();
		Cstring title = finder.GetFileName();
		ifstream fin (title);
		if(!fin) 
		{
			cout<< "cannot open input file \n";
			return 1;
		}	
		ofstream fout ("merge.cf"); 
		if (!fout) 
		{	
			cout<< "cannot open output file .\n";
			return 1;
		}
//..............................................................
		if(firstFile)
		{
			while (!fin.eof())
			{
				getline (fin,line1);
				getline (fin,line2);
				if (end_str==line2)
					condition=1;
				else 
					condition=0;
				if(!condition)
					fout<<line1<<'\n';
				else
					fout<<line1;
			}
			firstFile=0;
		}
		else 
		{
			getline (fin,line1);
			fout<<'\n';
			while (!fin.eof())
			{
				getline (fin,line1);
				fout<<line1<<'\n';
			}
		}
		fout.close();
	}
	finder.Close ();
	return 0;
}
William Hemsworth 1,339 Posting Virtuoso

you are right ....i'm still in the process to understand c++.....i want to make a game that involve throwing or launching of an object but it must have at least one obstacle partially obstructing the throwing path (for example: a high wall) and at least one other difficulty for the player, such as passing birds(which get in the way), or an environmental effect such as wind. can you help me with that... ?

Hehh.. good luck with that.. :icon_wink:

I seriously recommend you buy a book on C++, as you clearly don't know how difficult it is to accomplish something like this. Take a look at this thread. http://www.daniweb.com/forums/thread70096.html

William Hemsworth 1,339 Posting Virtuoso

As far as I see here it should be: notepad = FindWindow(NULL, "Notepad");

Nope, the first parameter is the class name, which in this case is "Notepad", the second parameter is for the window name, which if you don't know, can be left as NULL, although I guess you could set it to the default "Untitled - Notepad", however the caption isn't guaranteed to be this, as once you open a file, it changes.

William Hemsworth 1,339 Posting Virtuoso

>'FindWindowW' : cannot convert parameter 1 from 'const char [8]' to 'LPCWSTR'
> 'MessageBoxW' : cannot convert parameter 2 from 'const char [26]' to 'LPCWSTR'
> 'CreateWindowExW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR'

Turn off the unicode character set, you can do this a few ways, either change your compiler settings, or at the very beginning of your code (before the includes) add:

#undef UNICODE
William Hemsworth 1,339 Posting Virtuoso
William Hemsworth 1,339 Posting Virtuoso

This to me seemed like quite an interesting idea, so I had a go at it. The only real problem I had is painting problems (which can probably quite easily be sorted out). This sample program will assume that notepad.exe is already open before this program is executed. It then sets notepad as a child window of the main window I made. Heres the code:

#include <windows.h>

const char ClassName[] = "WndClassName";

HWND notepad;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
   switch (msg) {
      case WM_CLOSE:
         {
            DestroyWindow(hwnd);
         }
         break;
      case WM_CREATE:
         {
            // Find notepad.exe window
            notepad = FindWindow("Notepad", NULL);

            // Check if notepad exists
            if (!notepad) {
               MessageBox(hwnd, "Notepad not open, closing", "Error",
                          MB_OK | MB_ICONERROR);
               DestroyWindow(hwnd);
            }

            // Set it as a child window
            SetParent(notepad, hwnd);

            // Resize and position it to make it visible
            SetWindowPos(notepad, NULL, 0, 0, 300, 300, NULL);
         }
         break;
      case WM_DESTROY:
         {
            PostQuitMessage(0);
         }
         break;
      default:
         return DefWindowProc(hwnd, msg, wParam, lParam);
   }
   return 0;
}

int CALLBACK WinMain(HINSTANCE hInstance,
            HINSTANCE hPrevInstance,
            LPSTR lpCmdLine,
            int nShowCmd) {
   HWND hwnd;
   WNDCLASSEX wc;
   MSG msg;

   wc.cbWndExtra = 0;
   wc.cbClsExtra = 0;
   wc.cbSize = sizeof WNDCLASSEX;
   wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
   wc.hCursor = LoadCursor(NULL, IDC_ARROW);
   wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
   wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
   wc.hInstance = hInstance;
   wc.lpfnWndProc = WndProc;
   wc.lpszClassName = ClassName;
   wc.lpszMenuName = NULL;
   wc.style = 0;

   if (!RegisterClassEx(&wc)) {
      return 1;
   }

   hwnd = CreateWindowEx(
      WS_EX_APPWINDOW,
      ClassName,
      "Window Owner",
      WS_MINIMIZEBOX | WS_MAXIMIZEBOX|
      WS_SYSMENU | WS_CAPTION | WS_THICKFRAME,
      CW_USEDEFAULT, CW_USEDEFAULT,
      CW_USEDEFAULT, …
William Hemsworth 1,339 Posting Virtuoso
William Hemsworth 1,339 Posting Virtuoso

Another way to do this.

#include <iostream>
using namespace std;

class Item {
private:
   int node;											

public:
   Item();
   Item(int);
   operator int();

   ~Item();
};

Item::Item() {
   node = 0;
}

Item::Item(int n) {
   node = n;
}

Item::operator int() {
   return node;
}

int main() {
   Item* items[10];

   items[0] = new Item(5);
   items[1] = new Item(3);
   items[2] = new Item(4);
   items[3] = new Item(9);
   items[4] = new Item(2);
   items[5] = new Item(0);
   items[6] = new Item(6);
   items[7] = new Item(1);
   items[8] = new Item(8);
   items[9] = new Item(7);

   for (int i = 0; i < 10; i++) {
      cout << *items[i] << endl;
   }

   cin.ignore();
   return 0;
}

Whenever an variable (type Item) is used, it will be recognized as an int by what is returned from the Item::operator int() function.

William Hemsworth 1,339 Posting Virtuoso

Post some code which shows the Item class please.

William Hemsworth 1,339 Posting Virtuoso

>make a simple program
If its so simple, why can't you do it?, or at least make an attempt at it.
All you need to know to be able to do this, is how to use nested loops and from there i'm sure you could figure it out yourself.

William Hemsworth 1,339 Posting Virtuoso

Why dont you read the link you gave us??!