Forum: C++ Mar 20th, 2009 |
| Replies: 17 Views: 1,174 You cannot asign an unknown value to the size of an array at compile time. You need to use dynamic memory.
double *P = new double[N];
...
delete [] P;
For the second bit, you cannot do a... |
Forum: C++ Mar 12th, 2009 |
| Replies: 10 Views: 687 Perhaps his real question is how can he compute the value of that series to a given figure amount using C++? |
Forum: C++ Mar 6th, 2009 |
| Replies: 5 Views: 290 Please use code tags, .
Firstly, is this C or C++ because it looks like a strange confusion between the two. The only header you should be using in this program is #include <iostream> not with a... |
Forum: C++ Feb 25th, 2009 |
| Replies: 2 Views: 321 Well you might want to use getline(), but the reason it doesn't work is that the ifstream constructor requires a C-Style string i.e. null terminated character array, not an object of type string.... |
Forum: C++ Feb 13th, 2009 |
| Replies: 5 Views: 1,006 The other option would be to close the file stream and then re-open, btw be sure to check that you actually need to read the file stream twice, rather than loading it contence into some data... |
Forum: C++ Feb 13th, 2009 |
| Replies: 7 Views: 431 I think you should re-read your previous thread about creating 2D arrays witht he new operator. Look at the following two lines, If I remember correctly, I stated that to create a two dimensional... |
Forum: Java Feb 12th, 2009 |
| Replies: 4 Views: 832 Are you talking about printing out the source code??
If so research Quinnes :)
Chris |
Forum: Java Feb 11th, 2009 |
| Replies: 3 Views: 627 Rectangle myRectangle = Rectangle(); should be Rectangle myRectangle = new Rectangle();
The second too, I suggest you look at the function. Notice you declare them as taking two parameters yet you... |
Forum: C++ Feb 10th, 2009 |
| Replies: 4 Views: 1,619 Project -> Build Options -> Linker -> add -> gdi32
Chris |
Forum: C++ Feb 9th, 2009 |
| Replies: 4 Views: 1,619 You need to link "gdi32.dll" into your project :)
Chris |
Forum: C++ Feb 7th, 2009 |
| Replies: 6 Views: 724 Well you are not storing them into the array such as, a[x][y]. And your show function shouldn't be recoursive like that...it doesn't even print things out, it just cause lots of problems.
Chris |
Forum: C++ Feb 7th, 2009 |
| Replies: 6 Views: 724 inFile >>row >>col;This is the only line that reads data in from the file, its not looped or anything. This reads 1 integer, then skips whitespace and reads another. The fact that you don't even... |
Forum: C++ Feb 7th, 2009 |
| Replies: 4 Views: 413 Why don't you have a look at something like QT. It would be a whole lot easier. But yes you could do this anyway.
Chris |
Forum: C++ Feb 7th, 2009 |
| Replies: 6 Views: 724 Looks to me like you only read in 2 numbers from your text file. Then you go ahead and start printing out un initialised memory space....
Chris |
Forum: C++ Feb 6th, 2009 |
| Replies: 7 Views: 394 <> state the file is located in the include directories.
"" states it may be located in the same location as the main source file.
(something like that) You need all the files in the same... |
Forum: C++ Feb 6th, 2009 |
| Replies: 7 Views: 394 When doing this, the method is normally to have aheader file containing the function prototype. A Cpp file containing the function declaration and the a main cpp file that contains your int main(int... |
Forum: C++ Feb 5th, 2009 |
| Replies: 24 Views: 1,117 ostream& operator<<(ostream& os, Book& b){
cout<< "Title: " << "\"" << b.title << "\"" << endl;
cout<< "Author: " << b.author << endl;
cout<< "Genre: " << b.genre << endl;
cout<< "Publisher:... |
Forum: C++ Feb 5th, 2009 |
| Replies: 4 Views: 303 What exactly is the character problem, '1' + '1' does = 'b'. What is your decode function is it not, 'b'-'1' = '1'.
Or did I miss something?
Chris |
Forum: C++ Feb 5th, 2009 |
| Replies: 9 Views: 845 Sorry if I come across rude. Yes alot of people do it, and they also get a LOT of stick for it thats for sure.
Chris |
Forum: C++ Feb 5th, 2009 |
| Replies: 9 Views: 845 This is my point, we are not paid. This means we volunteer out time to help provide you with a solution in which somebody on another site is already discussing in his/her own time. Meaning the same... |
Forum: C++ Feb 5th, 2009 |
| Replies: 4 Views: 303 encryptedLine += (line.at(pos) + password.at(pos2));
if (pos2 > password.size()) {
pos2 = 0;
}You try to retreive the value at pos2 when pos2 is > than password.size() before you reset pos2 to... |
Forum: C++ Feb 5th, 2009 |
| Replies: 9 Views: 845 So who do you want to answer it or are you happy wasting the time of two sets of people?
Chris |
Forum: C++ Feb 5th, 2009 |
| Replies: 7 Views: 749 OK lets goover what i've done.
#include <sstream>
#include <fstream>
int main(int argc, char *argv[])
{
std::ofstream outfile("data.txt", std::ios::in);
std::ostringstream... |
Forum: C++ Feb 5th, 2009 |
| Replies: 7 Views: 749 it's your string stream, you need to clear it before adding more to it.
OUTPUT.clear()
Chris |
Forum: C++ Feb 4th, 2009 |
| Replies: 11 Views: 890 Lets say you are compiling with VC++ then your source code isn't in the same location as the debug or release exectuable, which means nore will "Dict.dat" be, this means you will need to move your... |
Forum: C Feb 4th, 2009 |
| Replies: 4 Views: 1,228 void *malloc ( size_t size );This is the function prototype, and as Agni stated it returns a void pointer. Since this is the function prototype you do not use this syntax when calling the function... |
Forum: C++ Feb 4th, 2009 |
| Replies: 11 Views: 890 if(!inClientFile)Please do not use this method, it is so wrong. You would be better using the followingif(!inClientFile.good())Chris |
Forum: C Jan 30th, 2009 |
| Replies: 12 Views: 1,701 Please don't PM code solutions. I suggest re-reading the forums rules too. Just to make sure you understand how we work when it comes to handing out code.
Secondly, code solutions are best in the... |
Forum: C++ Jan 30th, 2009 |
| Replies: 4 Views: 916 What do you mean by 'Text'? As in an editable text control? or just writing painted onto the windows?
there is a big difference.
Chris |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 400 all of the lines to your if statement should be wrapped in {}.
Also using cin>> is a step backwards from getline() you should read the stick "How do I clear the imput buffer?"
Chris |
Forum: C++ Jan 28th, 2009 |
| Replies: 4 Views: 278 Sounds like you actually want something like this....#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc,... |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 400 istringstream iss;
iss.str("56");
int x;
iss >> x;
if(myArray[y] == x)
cout << "They match! at array position: " << y; |
Forum: C++ Jan 28th, 2009 |
| Replies: 4 Views: 278 Post a sample of your input file and a sample of what your output should be, and what output you are getting please.
Chris |
Forum: C Jan 28th, 2009 |
| Replies: 12 Views: 1,701 your desciption indicates that you will be given a list of random numbers that will be in no particualr order. thus you cannot just loop through the array backwards. You will need to perform some... |
Forum: C++ Jan 28th, 2009 |
| Replies: 5 Views: 2,095 #include <fstream>
#include <string>
int main(int argc, char *argv[]){
std::string example = "Hello, world!\nHow are you?\n\tSuper thanks!";
std::ofstream exfile("test.txt");
... |
Forum: C++ Jan 28th, 2009 |
| Replies: 8 Views: 400 You could use stringstreams (http://www.cppreference.com/wiki/io/sstream/start) to convert the string into an integer. Or you could use atoi() or even better strtol() you can research all of these on... |
Forum: C++ Jan 22nd, 2009 |
| Replies: 20 Views: 936 lol Year sorry, I wasn't really thinking, just stuck the numbers in without thinking :P |
Forum: C++ Jan 21st, 2009 |
| Replies: 2 Views: 860 You should have all prototypes in the header file and the full function delarations in the external file.
Chris |
Forum: C++ Jan 21st, 2009 |
| Replies: 11 Views: 533 This is C++ not C
Infact he has extra header file that he shouldn't have such as time.h
Please try to get things reasonbly accurate before making a point of it
Chris |
Forum: C++ Jan 21st, 2009 |
| Replies: 20 Views: 936 if (h < 0)
{
return 1; // error code +1 = underflow hours
}
else if( h > 59 )
{
return 2; // error code +2 = overflow hours
}:) |