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 ...
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 ...
You have to put your header file in the header files folder of your project ...
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 ?
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) !
...
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 ...
Srry I didn't read your post carefully ...
...
I know, but some operating systems like Unix and Linux aren't liking it if your program doesn't return an exit code ...
#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;
?
A shorter way to write i = i + 1;
: i++;
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 !
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 !
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 ...
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 ...
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 ...
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 !
Yeah, it's NEVER recommended to use 2 AVs at the same time as they will interfere with each other, only causing trouble ...
Yeah you're absolutely right, but you've to know the basics of C++ ...
Thanks everyone especially NARUE. I wish you were my professor.
Who wouldn't ? :)
I know a book where it's explained in: "The Art of C++" by Herbert Schildt ...
Srry, I forgot to post the link :) ...
Did you already notice that this is a 4-year old thread?
So, please stop posting here !
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 ...
I think you're actually writing a very small C++ interpreter ...
'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 ...
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 ...
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) ...
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 ...
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 !
Can you tell me what output you have and why you don't like it ?
Maybe the following pages are interesting to you:
> http://math.hws.edu/eck/cs225/s03/binary_trees/
> http://en.wikipedia.org/wiki/Binary_search_tree
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 ...
Check out the following links about sudoku solving: http://www.sudokusolver.co.uk/solvemethods.html
http://en.wikipedia.org/wiki/Algorithmics_of_sudoku
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 ...
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 ...
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) ...
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 ...
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 ...
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)
To read a whole line from a file: std::getline(<filename>, <string>);
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) ...