Search Results

Showing results 1 to 40 of 405
Search took 0.04 seconds.
Search: Posts Made By: niek_e ; Forum: C++ and child forums
Forum: C++ 12 Hours Ago
Replies: 10
Views: 193
Posted By niek_e
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++ 14 Hours Ago
Replies: 10
Views: 193
Posted By niek_e
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++ 19 Hours Ago
Replies: 10
Views: 193
Posted By niek_e
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++ 1 Day Ago
Replies: 9
Views: 210
Posted By niek_e
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++ 3 Days Ago
Replies: 7
Views: 179
Posted By niek_e
We (try to) help everyone here from beginner to pro. So stick around ;) We all started out at the bottom.
Forum: C++ 3 Days Ago
Replies: 7
Views: 179
Posted By niek_e
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++ 11 Days Ago
Replies: 6
Views: 411
Posted By niek_e
This may very well be the best post I have ever read on Daniweb. :icon_mrgreen:
Forum: C++ 13 Days Ago
Replies: 5
Views: 219
Posted By niek_e
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: C++ Oct 22nd, 2009
Replies: 5
Solved: MFC Tutorial
Views: 365
Posted By niek_e
I learned it from here (http://www.functionx.com/visualc/)
Forum: C++ Oct 21st, 2009
Replies: 3
Views: 314
Posted By niek_e
You forgot to #include <sstream>
Forum: C++ Oct 16th, 2009
Replies: 9
Views: 336
Posted By niek_e
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
Solved: C++ problem
Views: 586
Posted By niek_e
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
Solved: C++ problem
Views: 586
Posted By niek_e
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
Solved: C++ problem
Views: 586
Posted By niek_e
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
Solved: Poll: readout
Views: 264
Posted By niek_e
So exactly why didn't you try my code?
Forum: C++ Oct 8th, 2009
Replies: 5
Solved: Poll: readout
Views: 264
Posted By niek_e
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: C++ Sep 24th, 2009
Replies: 4
Views: 334
Posted By niek_e
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: 314
Posted By niek_e
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: 314
Posted By niek_e
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: 478
Posted By niek_e
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: 298
Posted By niek_e
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: 298
Posted By niek_e
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: 478
Posted By niek_e
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: 511
Posted By niek_e
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 16th, 2009
Replies: 19
Views: 615
Posted By niek_e
I'll take a guess: Compiler error. :icon_wink:
You probably meant: cout << i;
Forum: C++ Sep 10th, 2009
Replies: 14
Views: 481
Posted By niek_e
You could also post the actual code here, so we can help you instead of continue guessing. :icon_wink:
Forum: C++ Sep 10th, 2009
Replies: 12
Views: 520
Posted By niek_e
Exactly. One of the other typos I still make now and then is :
if (a=1) versus if (a==1)

Which can also give you a headache..
Forum: C++ Sep 4th, 2009
Replies: 2
Views: 262
Posted By niek_e
It depends on which file you modified. If you've changed a header-file which is included by other (source) files, all those files need to be re-compiled because they depend on the changed header.
If...
Forum: C++ Sep 2nd, 2009
Replies: 4
Views: 1,843
Posted By niek_e
It's been a while since I've used fedora, but you might also need to install
yum install libstdc++6 or for 64bit yum install lib64stdc++6. I'm not sure if fedora installs them by default, although...
Forum: C++ Aug 28th, 2009
Replies: 13
Views: 506
Posted By niek_e
Let me spell this out for you:

ASK. A. QUESTION.
Forum: C++ Aug 28th, 2009
Replies: 13
Views: 506
Posted By niek_e
You really aren't the sharpest knife in the shed are you? Why don't you listen to good advice when someone gives it to you (http://www.daniweb.com/forums/post960283-5.html)?
Forum: C++ Aug 27th, 2009
Replies: 7
Views: 267
Posted By niek_e
Call it with 2 variables as you've declared it, so change:
name(name2); to name(name1, name2);
Forum: C++ Aug 27th, 2009
Replies: 9
Views: 381
Posted By niek_e
It might help if you actually asked a question instead of just wacking some code online and hope for the best.
Forum: C++ Aug 27th, 2009
Replies: 7
Views: 267
Posted By niek_e
A correction on Adatapost's post:
This line: std::cout << a << " " << b;

should actually be : std::cout << a << " " << n;

A small typo :)
Forum: C++ Aug 24th, 2009
Replies: 3
Views: 229
Posted By niek_e
A few things are wrong with your code:

if (PlayerStamina < 40 || PlayerStamina > 35) {

You're saying : if PlayerStamina is smaller then 40 or bigger then 35.. Read this line very carefully and...
Forum: C++ Aug 18th, 2009
Replies: 9
Views: 339
Posted By niek_e
here's how to do it:

- go to [project]-->[...... properties]
- go to [configuration properties]-->[linker]-->[input]
- click "Additional dependencies" and add your libs.
Forum: C++ Jul 29th, 2009
Replies: 5
Views: 468
Posted By niek_e
You did not yet make a function to display the structs yet. So you will need to create somethink like:


void Display(Moviedata moviein){
// display the thing here instead of in main
return;...
Forum: C++ Jul 29th, 2009
Replies: 1
Solved: Array in class
Views: 209
Posted By niek_e
The problem is that when the class is created, n and m do not have a value yet, so the compiler doesn't know how big you want your array. So you need to dynamicly create the array using new and...
Forum: C++ Jul 24th, 2009
Replies: 19
Views: 601
Posted By niek_e
It's means the i-th object in the vector. In other words: If you say inv.at(i) you get the left most book on the shelf. inv.at(1) will get you the second from the left etc.



correct!


...
Forum: C++ Jul 24th, 2009
Replies: 19
Views: 601
Posted By niek_e
You'll be amazed with my patience :)



vector<string> means that I'm declaring a vector (http://www.cplusplus.com/reference/stl/vector/vector/)of strings. So when I say void...
Showing results 1 to 40 of 405

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC