u8sand 68 Junior Poster

Ok. Well I'm guessing its not possible unless I compile it before hand basically. Thanks for the feedback.

u8sand 68 Junior Poster

If you would like, in your default constructor use your setLengthAndWidth(1.0,1.0) function then in that function also calculate the perimeter and area, so when you set the length or width the new area/perimeter's are calculated.

u8sand 68 Junior Poster

Well for one, you've never calculated perimeter and area, so its going to be the crazy value because the value was never set. However the other objects generating strenuous results with the length and width I'm not sure if they will remain when you fix the calculating of the perimeter and area, but you may want to make a constructor of Rectangle type especially since object5 is set to object2

Rectangle(const Rectangle& rect)
{
    length = rect.length;
    width = rect.width;
    perimeter = rect.perimeter;
    area = rect.area;
}

hope this helps, reply if the problem persists.

u8sand 68 Junior Poster

Ok so I've used function pointers for some time. I was trying to figure out if this was possible.

First. It IS possible to convert a function pointer into an array of bytes.

It is also possible to reconstruct that function with the bytes in that array.

I would like to save a function into an array of bytes, and lets say save it to a text file (func.dat). Then later read that text file and execute the particular function...
Is it possible? It seems it should be possible the only problem I run across is finding the size of the array that makes up the function.

Is there any way to do this?

int func()
{
    return 1+1;
}

int main()
{
    int (*foo)() = func;

    char* data = (char*)func;

    // write all the data
    char* copyFunc = new char[sizeof(func)];
    for(int i = 0; i < sizeof(func); i++)
        copyFunc[i] = data[i];

    int (*constructedFoo)() = (int (*)())copyFunc;

    return 0;
}

of course this code won't compile because sizeof does not work for functions, does anyone know how to get the size of a function? Or the size of the function header/footer.

I have tried things like

int func()
{
    1+1;
    new char('}');
}

Then searched for the } char (as the end of the function) but that size doesn't work.


If your wondering why I need it, it could be used for lets say, sending a function to a …

u8sand 68 Junior Poster

Thank you so much, such a simple error i overlooked. Everything works now.

u8sand 68 Junior Poster

I programmed this vector class to support different types and different amount of dimensions. (class T,int D) D is the dimension.

I don't use templates much and I'm running into an error, my constructors aren't working.

Here is my class

#include <stdio.h>
#include <stdarg.h>

template <class T,int D>
class Vector
{
public:
    Vector();
    Vector(...);
    Vector(const Vector<T,D>& vec);
    ~Vector();

    const Vector<T,D>& operator=(Vector<T,D>);

    Vector<T,D> operator+(Vector<T,D>);
    Vector<T,D> operator-(Vector<T,D>);
    Vector<T,D> operator*(Vector<T,D>);
    Vector<T,D> operator/(Vector<T,D>);

    const Vector<T,D>& operator+=(Vector<T,D>);
    const Vector<T,D>& operator-=(Vector<T,D>);
    const Vector<T,D>& operator*=(Vector<T,D>);
    const Vector<T,D>& operator/=(Vector<T,D>);

    bool operator==(Vector<T,D>);
    //bool operator==(T);

    //bool operator> (Vector<T,D>);
    //bool operator< (Vector<T,D>);
    //bool operator>=(Vector<T,D>);
    //bool operator<=(Vector<T,D>);
    //bool operator> (T);
    //bool operator< (T);
    //bool operator>=(T);
    //bool operator<=(T);

    T& operator[](const int& index);

    //operator const T();
private:
    //int Length();

    T* dim;
};

template <class T,int D>
Vector<T,D>::Vector()
{
    if(D > 0)
    {
        dim = new T[D];
        for(int i = 0; i < D; i++)
            dim[i] = 0;
    }
}
template <class T,int D>
Vector<T,D>::Vector(...)
{
    if(D > 0)
    {
        va_list dims;
        va_start(dims,D);
        dim = new T[D];
        for(int i = 0; i < D; i++)
            dim[i] = va_arg(dims,T);
        va_end(dims);
    }
}
template <class T,int D>
Vector<T,D>::Vector(const Vector<T,D>& vec)
{
    if(D > 0)
    {
        dim = new T[D];
        for(int i = 0; i < D; i++)
            dim[i] = vec.dim[i];
    }
}
template <class T,int D>
Vector<T,D>::~Vector()
{
    if(D > 0)
        delete [] dim;
}
template <class T,int D>
const Vector<T,D>& Vector<T,D>::operator=(Vector<T,D> v)
{
    if(D > 0)
    {
        delete [] dim;
        dim = new T[D];
        for(int i = 0; i < D; i++)
            dim[i] …
u8sand 68 Junior Poster

This may seems like a lame question but I have yet to find something online helping me with my problem. Many websites you go to (excluding this one) instead of putting bla.php?id=2 they will have a url that looks like its in a folder or something like: /bla/2 An example would be a news site, they would have the "folders" as the date of the article news/8-23-2010/title not.. news.php?date=8-23-2010&title=title.
So could some one either tell me how to do this or give me a link to a site that tells me how to do this. I understand you may have to edit one of php's ini files but I don't currently own my own webserver. If a subdomain offers php shouldn't it allow this feature?

Thank you and sorry if the title was challenging to understand.

u8sand 68 Junior Poster

You want the mouse just to appear somewhere or do you want it to magically move across the screen?

u8sand 68 Junior Poster

I love it! Would it be possible to make cin.get() save the string as well as the escape character (commonly '\n'). This way it wouldn't ever be 'nothing' because you'd always get the \n character at least. I also have much use for the \n character because its easy to remove and sometimes annoying to re-add.

u8sand 68 Junior Poster

Go to Project -> Project Options

It opens a dialog box, go to parameters, under linker look for -lobjc
When you find it delete it. That parameter was not found by the compiler.

u8sand 68 Junior Poster

It wasn't working, when I showed again it wouldn't show up. I believe the close event is still being called and the window's code destructs the window making it no longer usable.

Any other ideas?

u8sand 68 Junior Poster

Hello,
Recently I've been doing some Windows API programming and I came across a problem. I want to make a console program that accepts commands, when the command 'win' shows up it will create a window with some automated features.

Lets say I had a command sendfile [file-path] [where]. I'd like the GUI to allow me to browse the file, and select where from a list of some kind. But the problem I'm having is I'm unsure how to make it so when you close the GUI window it will simply hide and I can call it back through my console window. Currently I've managed to make it go away once but when you try win again it doesn't show up. I also made it so every time you type win it will create the window. That works but it wont save previous data on the forum because it is destroying it and recreating.

Does anyone know how to cancel the close event and make the window hide instead.?

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        case WM_QUIT:
            // cancel ?
            ShowWwindow(hwnd,SW_HIDE);
            break;
        default:
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

Thank you in advance for reading my long and useless explanation.

u8sand 68 Junior Poster

Your problem proves not that you don't have an understanding of arrays but that you do not have an understanding of how objects work. Notice at the beginning of your array declaration you put 'int' but then inside ALL of the data are STRINGS, not INTEGERS. Also if your going to make them STRINGS use double quotes: single quotes is only for single characters.

Lastly, based on the array declaration I'm having much trouble understanding exactly what your array is for.

I'm also sorry if I sounded rude in my post, no rudeness intended.

u8sand 68 Junior Poster

To be able to assign your object to various things you need to make some constructors, it will then be simple to implement your addition operator.
Constructor being:

public:
    BigInt();
    BigInt(const int);
    BigInt(const char*);
    BigInt(const BigInt&);

Of course you can add more..
Then your operator+ is simply:

BigInt& operator+(const BigInt&);

If this is for an assignment it may have to be gone through another way but this is how I would do it.

u8sand 68 Junior Poster

worked tyvm, so i knew how to do it but i had to include the session start over every page that uses the session. Thanks.

u8sand 68 Junior Poster

I'm sorry, I can't help you if I don't even see the class. Please post the contents of String2.cpp
I'm assuming the class is named String? You probably get an error where it says "**** this is where error is ****" because of constructor issues.
Anyway please post String2.cpp's contents, I would help you but I'm about to leave. Maybe someone else can help you.

u8sand 68 Junior Poster
#define MAX_LENGTH 256
int main(void) {
    char userInput[MAX_LENGTH]; // use a character array not string
    
    cout << "Enter a string to be converted:" << endl;
    cin.get(userInput,256); // cin.get(char*,int) not cin >> ;
    cin.ignore(); // ignore the leading '\n' character
    for (int index = 0; index < strlen(userInput) /* strlen gives you the length of a character array */; index++) {
        cout << userInput[index] << endl;
        }
    system("pause");
    return 0;
}

didn't realize the "never-mind" : o hope this helps you anyway.

u8sand 68 Junior Poster

Hello guys,
I'm creating my own website-it's coming along very well but I'm stuck. There is a login, so that you can login to your account. Each account has an access of 1-10, if your access is 0 you are not logged in. When you put your username and password it checks all of the accounts in the mySQL database. That all works fine, but along with this is a forum, if you are logged in you can post ext.. in the forum, if your not logged in you can only view it. I made it so you can view it but how would i have a variable that worked through all the pages in my website so the forum could say do they have an access of greater than 0?
So i thought... Sessions

My default.php runs includes the different things which include each other and it all works out so that its always "technically" on default.php.

<?php
// Start the session
session_start();
$_SESSION['Username'] = "";
$_SESSION['Access'] = 0;
?>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Website</title>
</head>
<body>
<table width="100%" height="100%" border="0">
<tr height="1%">
<td>
<?php require "menubar.php"; ?>
</td>
</tr>
<tr height="10%">
<td>
<?php require "logo.php"; ?>
</td>
</tr>
<tr valign="top">
<td>
<?php require "main.php"; ?>
</td>
</tr>
</table>
</body>
</html>

I'm not sure if I just don't know how to use Session variables or I'm using them wrong.

here is login.php

<html>
<body>
<?php
if(strlen($_POST['user']) == 0 || strlen($_POST['pass']) == 0)
{ …
u8sand 68 Junior Poster

Thanks.
I looked at w3schools but when i did things with php, when i ran it on my webpage it didn't do anything. php is very close to javascript accept for that fact that you need $ signs on variables. I know semi the basics, but don't understand how your suppost to create the database or use mySQL, nore do i know how to link it with html. For example I don't even know how to make a button actually do something.
I can't find a free open source one either. I would rather make my own but i may be able to figure a little out if i find one.
Still don't know where i should go. I will check w3schools again out. Anyone else?

u8sand 68 Junior Poster

Hello, I have my own website where I make programs and put them up on my web page, it has info on the programs ext.. I also allow other people to put up they just have to e-mail me with a specified template. But I want to make this easier for myself and everyone using my web page. I want to be able to click a button right on the downloads place that allows me to "post" a download. I also wanted to add a discussion forum and connect the news section of the forum with the news on the main page as well as connect the downloads on the main page to the downloads on the forum.

I am using the www.zymic.com web host which supports php and MySQL so I have been searching through google looking for a tutorial on them together. I have not found ANYTHING on how to make a forum of my own, only small tutorials to do one thing.

The main thing i don't understand is how to connect php with MySQL and how to make a forum with php...

Thanks allot in advance.

u8sand 68 Junior Poster

Microsoft Update wants to install the latest version of Silverlight (KB970363) on my computer but every time it goes i get the same error. (A picture of the error is attached).
I tried browsing to the folder, but it still did not work. I tryed uninstalling so i could just install off of Silverlight's site but the un-installation gives me the same window. I deleted silverlights file in program files and tried again, but still the same problem. What should i do ? I'm using Vista.

Thanks.

These windows updates drive me crazy :/

u8sand 68 Junior Poster

CString is extict because it is from MFC which is extinct, they may have it available but it is not up to date with everything. Any bugs that they had when they were out are still there. There is no way you can fix that unless you reconstruct the whole CString class so i would try making your own string class or use something that is not MFC.

u8sand 68 Junior Poster

I don't expect febonacci numbers to be negative, so why not use unsigned, it will give you twice the amount you can go.
And %d calls an integer, not a long (so it will only show what an integer would show if it was at that value)
I would also recomend using int main() instead of void main().

Salem commented: It's not a recommendation, it's the law! +36
u8sand 68 Junior Poster

Some compilers that are stupid the gaurds still wont work, if that is so try using pragma once at the top.

#pragma once
u8sand 68 Junior Poster

The atoi function returns an integer from a string. So:

char buf[256];
// Ask for input here
cin.getline(buf,256);
int num = atoi(buf);
if(num == 0) // atoi returns 0 if it is invalid
    cout << "Error";

Which is why you retrieve the input with a string (because a string can handle any text input) and turn it into an integer if its valid.

u8sand 68 Junior Poster

The atoi function returns an integer from a string. So:

char buf[256];
// Ask for input here
cin.getline(buf,256);
int num = atoi(buf);
if(num == 0)
    cout << "Error";
Thmyris commented: Helped so much ! Thank you ! +0
u8sand 68 Junior Poster

Your going to have to provide us with the GeneralTreeNode class please.

------------ edit -----------------
oh its a structure didn't see.. one sec lemme look this over again.
------------ edit -----------------

The only thing i can think of is that you did not declare the integers in the GeneralTreeNode structure, and therefore they are some crazy value giving you an error. But i think if that was the case you would just have gotten a crazy output not an error.

I don't know. maybe someone else knows. Sorry :/

u8sand 68 Junior Poster

I didn't really look at anything accept for the main function. Wouldn't it make sense to have a loop? It looks like your only calling the human to move once, then the computer the move once. Then the game ends... Shouldn't you loop until someone wins or something? And also please be more specific as to what your error is.

u8sand 68 Junior Poster

First of all, please surround your code with code tags or it makes it very hard for us to read. Second I would do this with array's, it seems it would make more sense, but this is an assignment.. Last, i would help you but you didn't do really anything just made a base and doesn't show me that you tried much.
I would love to help you but not enough effort was put into what you have so far.

You are not doing anything wrong, you just did not do anything accept for get it ready to be coded...

csurfer commented: Look at the code you didnt find even one mistake ??? thats strange... +0
u8sand 68 Junior Poster

O Sorry, it don't let me edit now -.-
Here:

int **array;
int sizeX,sizeY;
sizeX = 5; // set to whatever
sizeY = 5; // set to whatever
array = new int*[sizeY];
for(int i = 0; i < sizeY; i++)
    array[i] = new int[sizeX];
 
// Then to delete:
for(int i = 0; i < sizeY; i++)
    delete [] array[i];
delete [] array;
u8sand 68 Junior Poster

I would recommend:

int **array;
int sizeX,sizeY;
sizeX = 5; // set to whatever
sizeY = 5; // set to whatever
array = new int*[sizeY];
for(int i = 0; i < sizeY; i++)
    array[i] = new int[sizeX];

// Then to delete:
for(int i = 0; i < sizeY; i++)
    delete array[i];
delete [] array; // i think you need the [] here but not sure.

---------------------
This is what i used in something i made, but remade it here in 5 mins. No guarantee it works -.- Even though it should...

u8sand 68 Junior Poster

I also may recommend framesets. You can look into that, i recommend for almost all web programming: www.w3schools.com.

u8sand 68 Junior Poster

First of all, it would seem you have a Trojan Virus. It would also seem that it is re-running itself at startup. Whatever anti-virus you are using is not getting rid of it. When your anti-virus finds it, it should include a path. Attempt to navigate to that path and delete the program manually. This b.exe if part of the Trojan Virus, the fact that there is an error may mean that the one who coded the virus was not a very good coder -.-.
But anyway try deleting the file manually/ending the process via task manager (can be opend with ctrl+shift+escape or ctrl+alt+delete -> Open Task Manager) If you don't know how to do that, go to the process tab and look for b.exe, select it and press end task (as well as Trojan.exe is you find it).
I hope that helps.

this line in the logs you provided:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\6c153f40 (Trojan.Vundo.H) -> Quarantined and deleted successfully.
May mean that you have the "deadly" Trojan Vundo, which is Extremely hard to get rid of.

u8sand 68 Junior Poster

Firefox all the way. It's not the fastest though. Google Chrome is by-far faster than Firefox but still in it's BETA stage. ATM Firefox is the best possible browser to go with. It's open source, very well-known, many add-ons for it, fast, and stable. But no doubt Firefox is faster than IE like light is faster than sound :/

u8sand 68 Junior Poster

If you ask me, I would just get Firefox. It is better than IE in so many ways its not even funny. Firefox is open source, so chances of problems with ad-ons are minimal. Don't use chrome yet because it may be fast but it is still in it's BETA stage.

u8sand 68 Junior Poster

Usually Ubuntu take's control with the booting, but i think you may be able to boot into ubuntu if you do something with sys.exe -> Boot.
Also check Ubuntu's webpage. They may have a newer version for Windows 7 Dual Booting. Because Windows always wants to take control :/

u8sand 68 Junior Poster

I once tried to do something like this with ONLY C++. Tried to take all the contents of a document and remake it with the same thing. The problem is though that there are some characters that may not show up (may not follow ascii char set) and their may be text that is not being retrieved. Make sure your getting all the text, so use a pointer:

#include <iostream>
#include <fstream>

using namespace std;

char* main(char* file)
{
    char* contents;
    char* buffer;
    int numOfChars = 0;
    char ch;
    ifstream fin(file);
    if(fin)
    {
        while(fin.get(ch))
        {
            buffer = new char[numOfChars+2];
            for(int i = 0; i < numOfChars; i++)
                buffer[i] = contents[i];
            buffer[numOfChars] = ch;
            buffer[numOfChars+1] = '\0';
            delete contents;
            contents = new char[++numOfChars+1];
            for(int i = 0; i < numOfchars; i++)
                contents[i] = buffer[i];
            contents[numOfChars] = '\0';
            delete buffer;
        }
        fin.close();
    }
    else
        return "Error";
    return contents;
}
u8sand 68 Junior Poster
string str = "This    is a     sentence.";
string newStr;
int len = 0;
for(int i = 0; i < str.len; i++)
{
    newStr += str[i];
    if(str[i] == ' ')
        while(str[++i] == ' ')
            ;
}

I made this in 2 mins and didn't test it. But you get the basic idea..

u8sand 68 Junior Poster

I know that, I always find that books are better... Anyone know a good book on WindowsAPI ?

u8sand 68 Junior Poster

Couldn't Find much there :/

u8sand 68 Junior Poster

Hey guys,
I've been programming in consoles/visual C++. But i've been wanting to learn WindowsAPI programming WITHOUT the stupid visual interface for a while now. Could someone provide me some pointers on a good place i can learn this?
Right now I'm using http://www.winprog.org/tutorial/start.html

u8sand 68 Junior Poster

I would help you but you see. I'm only a beginner to Network Programming myself. I still have failed to find a good tutorial. When i try to compile it on DevC++ None of the headers are recognized. What compiler are you using, and in what operating system?

u8sand 68 Junior Poster

It is call-by Reference but you didn't use a reference anywhere.

--------- Edit ---------
Heh angi, you posted right before me -.-

u8sand 68 Junior Poster

You won't be reinventing the wheel if your using dlls from other software to make it. It will just basically be organizing and making your own GUI. If you really want to "Reinvent the Wheel" then make EVERYTHING yourself.
But it will be pretty hard to use the dlls unless you have a lib.

u8sand 68 Junior Poster

Please wrap your code in code tags with:

and a closing tag [/ code] (without the space)

and also, being new to programming, why would you start on networking? Why not try something simpler.[code=cplusplus]
and a closing tag
[/ code] (without the space)


and also, being new to programming, why would you start on networking? Why not try something simpler.

u8sand 68 Junior Poster

I am interested in making my own Hide to Tray program that will hide any program i choose to the tray. I already know how I'm going to do it.. all i need is to know how to hide another window.

In Visual C++ you do this->Visible = false; telling the main form's window to not be visible. I want to be able to do this to another window on your screen.

Any ideas?

u8sand 68 Junior Poster

Thanks i looked here didn't notice the stuff on the left tho xD

u8sand 68 Junior Poster

Win-Key is the same key that opens the start button. It is used for many windows shortcuts. Here's a list of them:

Win-Key : Start Menu
Win-Key + R : Run...
Win-Key + D : Show Desktop
Win-Key + F : Find
Win-Key + L : Lock
Win-Key + Tab : The cool vista scrolling through windows
Win-Key + # : Runs that # on your quick-launch bar

Someone may want to post all these in a thread and hope it gets pinned :P

u8sand 68 Junior Poster

Why not just zip it and password protect/encrypt?
Because system, read-only, archived, hidden files are annoying for the system, it keeps asking: "Are you sure?" on vista.

u8sand 68 Junior Poster

I looked on google for this all i found was people wanting it TO hibernate, it may seem weird but i DON'T want mine to. This way i can run a server on it without it glowing all night :/

Anyone know how to do this?