tux4life 2,072 Postaholic

I don't get your question ...

Actually an executable file is called a stand-alone application ...
So you CAN use it as a stand-alone application ...

tux4life 2,072 Postaholic

You have to put your header file in the header files folder of your project ...

tux4life 2,072 Postaholic

The following link may also be helpful:
http://msdn.microsoft.com/en-us/library/et4zwx34(VS.80).aspx

tux4life 2,072 Postaholic

I haven't received enough feedback to confidently say if this is a good enough and detailed enough article, but I'll suggest it anyway.

Did you write that information yourself ?

tux4life 2,072 Postaholic

Seems like you're using Microsoft Visual C++ ...

> Did you put the header file in the project ?
> Is the header file in the same directory as the '.cpp' file(s) where you're including it in ?

tux4life 2,072 Postaholic

BTW, Position =+ 1; is always setting variable Position to 1 ...

I think you meant Position += 1; (if your intention was to increment variable Position each time with one)

As a result your program will throw itself into an infinite loop (*) where it's always allocating more and more and more ... memory which explains the crash ...

(*): You're always checking whether Position < 47 , but this is always true as Position =+ 1; is everytime setting Position's value to 1, and 1 is always lower than 47 I hope this explains your mistake(s) !

tux4life 2,072 Postaholic

...
and btw you are leaking a lot of memory.

bryansworld, welcome to the world of C++ !

You're indeed leaking a lot of memory:
> What are you using variable 'strHolding' for ?
> Not very clever to insert the instruction strWord = new string[Position]; inside a loop as the program will always assign new memory and the old will still be allocated, but you don't have access to it anymore because you aren't having any pointer which is pointing to that memory ...

After you've rewritten your program:
> You shouldn't forget to release the allocated memory when it isn't needed anymore ...

tux4life 2,072 Postaholic

Srry I didn't read your post carefully ...
...

tux4life 2,072 Postaholic

I know, but some operating systems like Unix and Linux aren't liking it if your program doesn't return an exit code ...

tux4life 2,072 Postaholic

I think that wxWidgets will be a good choice for you ...

Actually it wouldn't be too difficult to learn, it offers you many features and it's cross-platform (and it's well documented) ...

If you want to read a good tutorial about it you should definitely check out this one ...

tux4life 2,072 Postaholic
#include<iostream>
#include "my.h"  //including the header file
int main()
{
my::a=56;
std::cout<<my::a;
}

Only a little remark but where is the return 0; ?

tux4life 2,072 Postaholic

This seems to be a good one ...
Or maybe this one ...

It's your choice !

tux4life 2,072 Postaholic

A shorter way to write i = i + 1; : i++;

tux4life 2,072 Postaholic

Why are you making it so difficult if you can keep it easy?
> Just use a simple configuration file ...

Why do you want to store some configuration options inside the program's exe? That's ridiculous !

tux4life 2,072 Postaholic

We only close threads when it violates one or more of the DaniWeb rules. Its perfectly acceptable to post in old threads as long as the new posts are on-topic and contain relevant information.

OK, I didn't know, thank you for the info !

tux4life 2,072 Postaholic

You could just go through the file and when your program comes across a '<' it should just ignore everything after it until it comes across a '>', at that point you've to count a tag ...

tux4life 2,072 Postaholic

And what about this one ?
Or this one ?

So far it seems there isn't a library which supports it so you'll maybe have to implement it yourself ...

tux4life 2,072 Postaholic

I think you're algorithm is pretty good so far:

if you're counting how much each character shows up in a word and then compare it to the ones of the other words it'll work in a good way ...

(What I also think is that this is something which can be solved in a more efficient way using the STL library)

I also found a much more inefficient algorithm than the one you're using:

I think it's way more inefficient to just try every possibility and compare it to the existing words ...

BTW, Could you post a copy of your source so we can take a look at what the 'inefficient' thing may be ...

tux4life 2,072 Postaholic

What you're asking for really is advanced programming, using an encrypted file (like MosaicFuneral said) will probably a much more simpler and less error-prone way to achieve the same thing ...

tux4life 2,072 Postaholic

Have you created a new project or have you just opened the file? Opening the file only prevents you from building the executable. You must create a project.

> That's right !

tux4life 2,072 Postaholic

Yeah, it's NEVER recommended to use 2 AVs at the same time as they will interfere with each other, only causing trouble ...

tux4life 2,072 Postaholic

Yeah you're absolutely right, but you've to know the basics of C++ ...

tux4life 2,072 Postaholic

Thanks everyone especially NARUE. I wish you were my professor.

Who wouldn't ? :)

tux4life 2,072 Postaholic

This seems to be what you need ...

tux4life 2,072 Postaholic

I know a book where it's explained in: "The Art of C++" by Herbert Schildt ...

tux4life 2,072 Postaholic

Srry, I forgot to post the link :) ...

tux4life 2,072 Postaholic

Did you already notice that this is a 4-year old thread?
So, please stop posting here !

tux4life 2,072 Postaholic

If you're using Windows Vista, it might be a better idea to use one of Microsoft's free available Express Editions, otherwise reinstalling the application might fix the problem ...

tux4life 2,072 Postaholic

I think you're actually writing a very small C++ interpreter ...

tux4life 2,072 Postaholic

'Advantages'? It depends on what you mean with it ...

They're both used to repeat a chunk of code as long as a condition is true, but using do-while, your code is executed one time at least ...

tux4life 2,072 Postaholic

We aren't giving free solutions and we aren't building programs for you ...

You should first show what you've done so far and ask specific questions about that what you don't understand ...

tux4life 2,072 Postaholic

Before your public methods you always have to add public: as in your posted code all the methods are private (If you don't define access specifiers in a class, all the data is standard private) ...

tux4life 2,072 Postaholic

Kings Of Leon - Sex On Fire

tux4life 2,072 Postaholic

If you can login on your Windows installation try the following:
Click the Start Button > Run > type: 'msconfig' (without the quotes)
In the window which came up select 'Diagnostic Startup' and click OK > Restart your computer ...

Now you should be able to start Windows without any crashes or BSODs ...

tux4life 2,072 Postaholic

I've changed your code a bit:

int log2(int n)
{
   int count = 1;
   
   while(n >= 1)
   {
	if (n%2 == 0)
	{
		count++;
		n=n/2;
	} else {
                count++;
                n=n/2;
                floor(n);
	}
   }
   
   return count-2;
}

I made changes to line 5 and to line 18 ...
On line 5 you're saying: while(!n >=1) well, actually the while is never run for values higher than or equal to 1 ...
Translated to human words: repeat this code IF n is NOT higher than 1 OR IF n is NOT equal to 1 ...
==> If you're dealing with values higher or equal to 1, the loop is never run as a result ...
Solution: Remove the '!'-sign and it works ...

In line 18: return count-2; because it was always returning values which were 2 higher than the actual solution ...

Hope this helps !

tux4life 2,072 Postaholic

Can you tell me what output you have and why you don't like it ?

tux4life 2,072 Postaholic
tux4life 2,072 Postaholic

I would like to add something to the description of 'inline' functions:
-> The compiler is always replacing an inline function call with all the instructions in the function ...
-> That's why it's recommended to keep the number of lines in an inline function as short as possible ...

tux4life 2,072 Postaholic
tux4life 2,072 Postaholic

You only have to write: \n to the file (as a string) ...
Could you please post the part of your code where you encounter this problem, so we can understand what you mean ...

tux4life 2,072 Postaholic
echo "<form type='contest.php' method='POST'>

Change that line to:

<form method="post" action="<?php echo $PHP_SELF;?>">

Consider using double quotation marks ...

I came up with this:
How do I ensure that the submit will go only toward the person who is logged-in's id in the database?

You can't prevent from submitting data to a PHP script ...

tux4life 2,072 Postaholic

To display a form from within a PHP script you can do the following:
> Use the echo-command to write the HTML-code (which is displaying the form) directly to the webpage
> You put the HTML code to view a form outside the PHP-tag(s)

You could also check out this page ...

tux4life 2,072 Postaholic

In one of the last lines I come across the following instruction: cin >> hold; If you're putting that instruction there to prevent the program from automatically closing: it's better to use cin.get(); instead ...
Please remember to also delete the variable declaration of 'hold' (somewhere in the first lines of your code) ...

tux4life 2,072 Postaholic

Is it possible to extract the filename from fstream?
> As far as I know NOT ...

BUT:
> You could simply store the filename in a string-variable (for later use) ...
> Or ... you could also derive a class from fstream and store the filename in the derived class ...

tux4life 2,072 Postaholic

I think that if you're dealing with normal computers multithreading will speed-up your program more than enough, but it's still the operating system which has the task to distribute those threads among all the available CPU-cores, so the efficiency also depends on what os you are using ...

tux4life 2,072 Postaholic

You're right, but normally it's the Operating System's task to distribute all the threads over the available CPU-cores ...

POSIX Threads is also available for Windows here ...
If you want to use Windows' native API you might want to check this ...

tux4life 2,072 Postaholic

What about POSIX Threads ?
Here's a tutorial about it ...

Hope this helps !

tux4life 2,072 Postaholic

To count the number of lines in a file you can use the following function:

int countLines(ifstream & file, string filename)
{
	file.close();
	file.open(filename.c_str());
	string line;
	int c = 0;
	
	while(getline(file, line))
		c++; // :-)
	
	file.close();	
	return c;
}

(But you could also write such a function yourself)

tux4life 2,072 Postaholic

To read a whole line from a file: std::getline(<filename>, <string>);

tux4life 2,072 Postaholic

Here's an example of what I mean:

#include <iostream>
#include <fstream>

using namespace std;

int main() 
{
	struct filestruct
	{
		int val_one, val_two, val_three;
	} test;
	
	test.val_one = 12;
	test.val_two = 13;
	test.val_three = 14;
	
	ofstream filestr;
	
	filestr.open ("test.txt");
	
	filestr << test.val_one << endl << test.val_two << endl << test.val_three;
	
	filestr.close();
	
    return 0;
}

This example is only showing you how to write the data to a file ...

You can use a similar method to read it back from the file (using an ifstream object instead of an ofstream object) ...