Forum: C++ 8 Days Ago |
| Replies: 7 Views: 267 You're probably thinking that you're resizing array's here:
int room_numbers[0][0];
string room_titles[0];
string room_description[0];
[....]
total_rooms =... |
Forum: Computer Science 10 Days Ago |
| Replies: 3 Views: 414 Correct.
Depending on what kind of data you're sending, so might need less stuffing if you use two bytes. Because the chance that the pattern of 2 bytes is in your data is a lot smaller then... |
Forum: C++ 16 Days Ago |
| Replies: 5 Views: 205 change #include <string.h> to : #include <string>
This should never have not compiled in G++, so that's strange.. |
Forum: C++ 17 Days Ago |
| Replies: 11 Views: 464 And why are you using "fprintf" and char-arrays in C++ code? This is the root of all your evil. Use std::strings instead. |
Forum: DaniWeb Community Feedback 17 Days Ago |
| Replies: 3 Views: 422 And the reason why you posted this in a forum instead of a PM is ....?
Be warned that you're pretty close to getting the last infraction that'll get you banned. Under "keep it pleasant... |
Forum: Visual Basic 4 / 5 / 6 18 Days Ago |
| Replies: 4 Views: 265 You need an extra variable. After you say: Text1.Text = Text2.Text text1 and text2 will both have the same text (from text2), so this Text2.Text = Text1.Text is useless.
Use something like:
tmp... |
Forum: Assembly 23 Days Ago |
| Replies: 1 Views: 423 From PM:
We don't delete posts here. You can just ignore this thread and mark it as 'solved' to ensure that no-one wasts his/her time on this. |
Forum: C++ 23 Days Ago |
| Replies: 10 Views: 408 I think you misunderstood me. Change all the getline(cin.ignore(), new_modify); back to getline(cin, new_modify);
What I meant was this:
int i =0 ;
string something = "";
cin >> i;... |
Forum: C++ 23 Days Ago |
| Replies: 10 Views: 408 Put a cin.ignore() after every cin >> ......
The reason (http://www.daniweb.com/forums/thread90228.html)you don't get a change to input anything is because "cin >>" leaves a '\n' on the input... |
Forum: C++ 23 Days Ago |
| Replies: 10 Views: 408 I suggest you use getline() to get input from the user. Getline takes in input until a newline (enter) is detected. This is handy in you case, because you need 2 words (first and last name).
To... |
Forum: C++ 24 Days Ago |
| Replies: 9 Views: 429 Vectors are indeed the way to go. But not with fixed sizes as recommended to you by 'other people'. Here's an example of what I mean:
#include <vector>
#include <iostream>
int main(){
... |
Forum: C++ 26 Days Ago |
| Replies: 7 Views: 399 We (try to) help everyone here from beginner to pro. So stick around ;) We all started out at the bottom. |
Forum: C++ 26 Days Ago |
| Replies: 7 Views: 399 this is wrong: mi = KM_MI * km;
"KM_MI" == km per mile. So if you already have km and want to go to miles, you should divide by this number, not multiply:
mi = km / KM_MI ;
Same error is in... |
Forum: C++ 34 Days Ago |
| Replies: 6 Views: 686 This may very well be the best post I have ever read on Daniweb. :icon_mrgreen: |
Forum: C++ Nov 18th, 2009 |
| Replies: 5 Views: 261 You need to change this line:
cout << “ ‘s bonus is ” << bonus << endl;
to:
cout << " bonus is " << bonus << endl;
without the fancy quotes, but with the plain old ones.
also: What... |
Forum: Python Nov 17th, 2009 |
| Replies: 2 Views: 259 You're using the pop() method of a list. It pop's a value from a list at INDEX x, not a VALUE x. So when you say that if i is smaller then 0: pop i You're removing the item at INDEX i. So when i ==... |
Forum: Geeks' Lounge Nov 16th, 2009 |
| Replies: 4 Views: 506 What kind of 'bot'? I hope you're not talking about spam and/or viruses. That would make me very unhappy with you :icon_frown: |
Forum: C++ Oct 22nd, 2009 |
| Replies: 5 Views: 468 I learned it from here (http://www.functionx.com/visualc/) |
Forum: C++ Oct 21st, 2009 |
| Replies: 3 Views: 343 You forgot to #include <sstream> |
Forum: DaniWeb Community Feedback Oct 18th, 2009 |
| Replies: 9 Views: 1,100 William is a *special* kind of guy ;) |
Forum: C++ Oct 16th, 2009 |
| Replies: 9 Views: 380 isdigit expects only 1 character, but you're giving it an char-array. That's because strtok returns an array of characters. See this page (http://www.cplusplus.com/reference/clibrary/cstring/strtok/) |
Forum: C++ Oct 9th, 2009 |
| Replies: 25 Views: 616 Yes you can. But then you have an uninitialized variable in your program. That's a bad thing. That's why I said: string name=""; |
Forum: C++ Oct 9th, 2009 |
| Replies: 25 Views: 616 Why don't you use a string for input? No need for char-arrays here, if you use std::getline(). Example:
#include <iostream>
#include <string>
using namespace std;
int main(){
string... |
Forum: C++ Oct 9th, 2009 |
| Replies: 25 Views: 616 Why do you want to change a string to a char? A char is ONE character, no more.
Post your newest code, with input and expected output. |
Forum: C++ Oct 9th, 2009 |
| Replies: 5 Views: 278 So exactly why didn't you try my code? |
Forum: C++ Oct 8th, 2009 |
| Replies: 5 Views: 278 Put a std::cin.get() (C++) or : getchar() (C) right before the return 0; in main().
int main(){
// do stuff
std::cin.get();
return 0;
} |
Forum: DaniWeb Community Feedback Oct 6th, 2009 |
| Replies: 3 Views: 530 |
Forum: Geeks' Lounge Sep 30th, 2009 |
| Replies: 3 Views: 329 Yeah, I actually reported is as a bug, but it turned out to be new and "improved" ;) |
Forum: DaniWeb Community Feedback Sep 29th, 2009 |
| Replies: 14 Views: 936 Problem already confirmed for IE, but now Firefox (3.0.14/XP) is also showing the bug.
11846 |
Forum: DaniWeb Community Feedback Sep 24th, 2009 |
| Replies: 14 Views: 936 My guess is that is has something to do with this (http://http://www.daniweb.com/twitter/tweet225345.html) |
Forum: C++ Sep 24th, 2009 |
| Replies: 4 Views: 357 40 members are a bit too much IMO. Have you considered using more then 1 class? For example:
class Human {
public:
Human::Human(std::string name, std::string last_name, int age);
private:... |
Forum: C++ Sep 23rd, 2009 |
| Replies: 4 Views: 363 As I said, to seed the randomgenerator
(http://www.cplusplus.com/reference/clibrary/cstdlib/srand/)
If you have time, you should read this (http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx) |
Forum: C++ Sep 23rd, 2009 |
| Replies: 4 Views: 363 did you seed the random-generator with srand() ?
Something like:
srand(time(NULL));
cout << rand()%v.size(); |
Forum: C++ Sep 22nd, 2009 |
| Replies: 12 Views: 532 I'm not sure about this, because I don't use managed code, but it looks like there's one ^ missing right before (1000). So perhaps:
List<List<String^>^>^ vector1 = gcnew... |
Forum: C++ Sep 22nd, 2009 |
| Replies: 6 Views: 323 You could use a loop that does 2 thing:
1. Check if there are still lines available in the file.
2. Check if the current linenumber is the line number you want.
example:
#include <iostream>... |
Forum: C++ Sep 22nd, 2009 |
| Replies: 6 Views: 323 Here's a tutorial (http://www.cplusplus.com/doc/tutorial/files/). Read it, and come back when you have questions/difficulties. |
Forum: C++ Sep 22nd, 2009 |
| Replies: 12 Views: 532 Short answer: you can't. Vectors and Lists are both sequence containers, so you'll need a "list of vectors" or a "list of lists" if you want to keep the structure in your data.
If you don't want... |
Forum: C++ Sep 20th, 2009 |
| Replies: 5 Views: 608 Your compiler isn't lying. You didn't delcare a, b,c or d here:
int main(void)
{
DivSales divSales;
divSales.addTotal(a,b,c,d); // <--- here
[....]
You should call the function... |
Forum: C Sep 18th, 2009 |
| Replies: 5 Views: 877 Your logic is wrong. 1 KM == 1000 M == 100000 CM. |
Forum: C++ Sep 16th, 2009 |
| Replies: 19 Views: 650 I'll take a guess: Compiler error. :icon_wink:
You probably meant: cout << i; |