Forum: C++ 4 Days Ago |
| Replies: 2 Views: 149 http://c-faq.com/aryptr/dynmuldimary.html |
Forum: C++ 4 Days Ago |
| Replies: 8 Views: 235 How about something along this line?
nclude <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream iptilvar("ip.txt"); //open filestram
string line, ip; |
Forum: C++ 5 Days Ago |
| Replies: 2 Views: 222 Are necessary headers #included prior to the lines in question?
The functions calls shouldn't have the [] part.
Do your headings have the curly-brace part?
Your code may be long, but you've... |
Forum: C++ 6 Days Ago |
| Replies: 8 Views: 251 My assistance has been subpar tonight. Try this:
void loadFileToArray (string namesArray[], double gradesArray[][4], int &numberOfStudents)
{
string filename;
ifstream inputDataStream;
... |
Forum: C++ 6 Days Ago |
| Replies: 8 Views: 251 Ah! Separate lines for the names and the grades! I stand corrected. My crystal ball file looked like this:
5
foo 95 84 72 87
bar 91 77 82 63
baz 75 63 66 42
qux 50 49 33 58
moo 92 95 97 91
noo... |
Forum: C++ 6 Days Ago |
| Replies: 8 Views: 251 I don't have this file or some other one that apparently works for you. From what I was tinkering with, I would be surprised with it having ever worked correctly. And since I haven't seen the input... |
Forum: C++ 6 Days Ago |
| Replies: 8 Views: 251 You've got nested loop issues.
After you get the line, the line is got. Reading "the rest of the line" will be problematic.
You should check for success when you attempt to read from the file.... |
Forum: C++ 9 Days Ago |
| Replies: 3 Views: 181 Keep track of the index of the highest value while taking input. Initialize to the first element:
int hi = 0;
When you find a new highest value, capture the index:
if ( votes[i] >... |
Forum: C 11 Days Ago |
| Replies: 4 Views: 243 The compiler warns because generally it isn't what someone wants. But multiplying by two is the same as adding self to self.
[edit]Heh. But that won't work with pointers. Probably also for good... |
Forum: C 15 Days Ago |
| Replies: 1 Views: 213 Expected input and output would be helpful. Providing a small snippet of a simple test, minimal but complete and compilable, would too.
"This code doesn't do what I want (and I'm not going to tell... |
Forum: C++ 16 Days Ago |
| Replies: 5 Views: 229 You seem to be using a lousy code editor and have "fancy quotes" instead of the plain variety. After that you'll get more syntax errors to clean up, like this
int calc_bonus(int sales){
You need to... |
Forum: C 16 Days Ago |
| Replies: 14 Views: 688 *sigh*
Of course it is. ALL structures of the structures in the first example are populated at compile time. A particular one isn't "selected" in the if tree. |
Forum: C 16 Days Ago |
| Replies: 14 Views: 688 Your first example may not be working the way you think it is. The #include directive is like a copy-and-paste that happens at compile time. You can't do it at runtime. |
Forum: C++ 19 Days Ago |
| Replies: 11 Views: 456 That happens to be true for the garden variety PC of today, but it is not true as a generic statement. |
Forum: C 21 Days Ago |
| Replies: 3 Views: 317 Are any of the suggestions here usable?
http://c-faq.com/varargs/nargs.html |
Forum: C 24 Days Ago |
| Replies: 2 Views: 206 getline is not standard C. |
Forum: C++ 25 Days Ago |
| Replies: 3 Views: 253 #include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << "RAND_MAX = " << RAND_MAX << "\n";
return 0;
} |
Forum: C 26 Days Ago |
| Replies: 6 Views: 207 Casting is misued a lot of the time. And I would argue that this would be a great example.
If the string itself is nonwritable, the cast silences the warning and passes this nonwritable string to... |
Forum: C 26 Days Ago |
| Replies: 6 Views: 207 Why not just turn off the warning? :icon_rolleyes: |
Forum: C 26 Days Ago |
| Replies: 6 Views: 207 Have the code mirror what you're doing:
char *VAR1(const char *VAR2)
Also, make sure you have enough space to write into.
[edit]If he wants the warning...
why would a solution be to silence... |
Forum: C++ 26 Days Ago |
| Replies: 2 Views: 180 Lose the semicolon:
#define CAPACITY 128;
[edit]Avoid expressions like this:
i=(i++)%CAPACITY
http://c-faq.com/expr/ieqiplusplus.html |
Forum: C++ 26 Days Ago |
| Replies: 4 Views: 256 Another way of reading "7 times per line" is "output a newline every 7 times". You could do this with a separate counter (in the same loop though!) that counts to 7, outputs a newline and then is... |
Forum: C++ 31 Days Ago |
| Replies: 6 Views: 484 Well, choose your poison: multiple passes of the same file, or a single read with a buffer. Both are relatively simple, I'd recommend just examining what's there. Experiment a bit. Learning to code... |
Forum: C++ 31 Days Ago |
| Replies: 6 Views: 484 I suppose you could read the file to count the lines and then back up and only print the last 10.
Why the extra condition now?
Why don't you give the coding a shot first? |
Forum: C++ 31 Days Ago |
| Replies: 6 Views: 484 I'd just read all lines of the file into a circular buffer with 10 strings, each containing a line. When you get to the end of the file, you will have the last 10 lines stored.
#include <iostream>... |
Forum: C++ 33 Days Ago |
| Replies: 12 Views: 377 You're going to return from main in one of two places:
int main ()
{
int number;
int counter = 0;
int flags = 1;
bool flag_none = true;
bool fag_yes = false;
cout << "Enter a number,... |
Forum: C++ 33 Days Ago |
| Replies: 12 Views: 377 The following code is unreachable:
if (counter < 7 == true)
{
cout << "Number " << counter << " is between 10 and 500" << endl;
cout << "Number " << counter << " is not flagged. " << endl;
}... |
Forum: C++ 33 Days Ago |
| Replies: 12 Views: 377 |
Forum: C++ Oct 29th, 2009 |
| Replies: 7 Views: 327 I had to patch some syntax errors to get to the link, so I'm not sure why you weren't seeing them. With regard to the linker errors:
http://parashift.com/c++-faq-lite/templates.html#faq-35.12 ? |
Forum: C Oct 25th, 2009 |
| Replies: 6 Views: 224 I wrote some snippets on parsing some time ago.
http://www.daniweb.com/code/snippet216535.html
http://www.daniweb.com/code/snippet216569.html
http://www.daniweb.com/code/snippet216682.html... |
Forum: C++ Oct 25th, 2009 |
| Replies: 14 Views: 350 No I don't. But it is working now thank you![/QUOTE]This would be an equivalent:
for ( int x=0; x<3; x++ )
{
/* empty loop */
} |
Forum: C++ Oct 25th, 2009 |
| Replies: 14 Views: 350 for ( int x=0; x<3; x++ );
Do you know what the semicolon does to your intended loop? |
Forum: C++ Oct 22nd, 2009 |
| Replies: 6 Views: 348 Hm. I don't see the mention -- perhaps it's my eyesight. But no matter. Clarification achieved.
I don't think I'd call it a compiler issue. I would think that perhaps there oughtta be a way to... |
Forum: C++ Oct 22nd, 2009 |
| Replies: 6 Views: 348 You kinda need to know whether the binary contains LE or BE data.
Some somewhat related FAQs:
http://c-faq.com/misc/endiantest.html
http://c-faq.com/cpp/ifendian.html... |
Forum: C Oct 22nd, 2009 |
| Replies: 2 Views: 243 http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_skip.aspx ? |
Forum: C++ Oct 19th, 2009 |
| Replies: 17 Views: 437 Hm. If only there were some way for the rest of us to see the code you have as currently modified. Perhaps you might consider, I dunno, posting it? |
Forum: C++ Oct 19th, 2009 |
| Replies: 17 Views: 437 Converting a string to a number is just about the most frequently asked question. Surely even a rudimentary search would give you a hint. (Part of learning to code is learning how to find answers.... |
Forum: C++ Oct 19th, 2009 |
| Replies: 17 Views: 437 So take input as a string, and if it's not "X", then convert it to a number. |
Forum: C++ Oct 19th, 2009 |
| Replies: 17 Views: 437 Some starters: Sort out your confusion about strings and numbers. Assignment is =, comparison is ==. Multiline blocks are not determined by indentation in this curly-brace language. |
Forum: C++ Oct 19th, 2009 |
| Replies: 4 Views: 324 Why it's bad to use feof() to control a loop (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351)
[edit]I think the "rt+" mode is a nonstandard extension meaning... |