Search Results

Showing results 1 to 40 of 115
Search took 0.01 seconds.
Search: Posts Made By: amrith92 ; Forum: C++ and child forums
Forum: C++ 13 Days Ago
Replies: 7
Views: 227
Posted By amrith92
More specifically, this is your problem (the one in bold):
bookinfo(int&, char [51], char [14], char [31], char [31], char [11], int&, double&, double&)

Try changing it to just int, as int& is...
Forum: C++ 14 Days Ago
Replies: 3
Views: 245
Posted By amrith92
Glad it helped! :) ... Sorry about the link, here's...
Forum: C++ 15 Days Ago
Replies: 3
Views: 245
Posted By amrith92
>> Now, if after reading the code the output isn't strange to you then my understanding of C++ is probably very wrong and I'm missing something obvious.

Well, as you've rightly guessed, the output...
Forum: C++ 17 Days Ago
Replies: 4
Views: 245
Posted By amrith92
>> Why it is necessary?

Well, it shouldn't be... I tried the code separately on both GCC and minGW compilers, and both compiled well and didn't complain...

Try adding the statement using...
Forum: C++ 17 Days Ago
Replies: 6
Views: 333
Posted By amrith92
>> Why do we need to add 1 to lineLength?

That's because when we declare an array, say int arr[5];, we are allocating, effectively 5*2 = 10 bytes of memory for it. Now, in your program, lineLength...
Forum: C++ 17 Days Ago
Replies: 6
Views: 333
Posted By amrith92
#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char *argv[]){

string line = "";
int lineLength = 0;
Forum: C++ 17 Days Ago
Replies: 10
Views: 285
Posted By amrith92
Then use both the constructors in the program :), like:

struct real
{
/*...*/
real(const double val);
real(double val, double err);
/* ... other constructors ... */
};
Forum: C++ 17 Days Ago
Replies: 8
Views: 347
Posted By amrith92
Could you attach a copy of the file "ip.txt", so that we can have a look at it? Further, how is the file generated, i.e, as another program's output, or written manually with a text editor?

You...
Forum: C++ 18 Days Ago
Replies: 10
Views: 285
Posted By amrith92
Which version of minGW are you using? I've tried the code on both my minGW and GCC Compilers, and they don't come up with any sort of error...

To the best of my knowledge(which might be bad), this...
Forum: C++ 18 Days Ago
Replies: 10
Views: 285
Posted By amrith92
I'm afraid I'm a bit confused by what you want to do... This is my understanding of your question:

1. You'd like to initialize objects of real using this syntax: real x = 1.;, where error is...
Forum: C++ 18 Days Ago
Replies: 10
Views: 285
Posted By amrith92
Okay, then how about:

#include <iostream>

using namespace std;

struct real
{
double value;
double error;
Forum: C++ 18 Days Ago
Replies: 10
Views: 285
Posted By amrith92
I'm not sure, but try:

real x = {1.};

With this, you wouldn't need to overload any operator...

Hope it helped!
Forum: C++ 18 Days Ago
Replies: 3
Views: 205
Posted By amrith92
Nope, that's absolutely fine. You won't need to change the function call, even if you add more code, that is unless and until you change the functions' arguments or something... :)
Forum: C++ 18 Days Ago
Replies: 8
Views: 347
Posted By amrith92
Why not try this:

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream iptilvar;
Forum: C++ 18 Days Ago
Replies: 8
Views: 428
Posted By amrith92
Agreed :) I wasn't defending the practice, but I was merely substantiating that it wasn't the problem juniper2009 was facing in the code provided...
Forum: C++ 18 Days Ago
Replies: 3
Views: 205
Posted By amrith92
Okay, before I answer your question, a few things need to be cleared. In all the code I've seen till now, <ionstream> is by far the most striking alternative to the known, and beloved <iostream>...
Forum: C++ 18 Days Ago
Replies: 8
Views: 428
Posted By amrith92
I'm glad it helped! :)

I'm still not very sure what you want isLowerCase for, and how it should be used in your program, but, here's how I understand your program:
1. Load the 10 characters into ...
Forum: C++ 18 Days Ago
Replies: 6
Views: 486
Posted By amrith92
Or you could just break out of the loop, using the break; statement; so that it'll stay open long enough for you to see that you've won... :)
Forum: C++ 18 Days Ago
Replies: 8
Views: 428
Posted By amrith92
Okay first things first...
What exactly are you trying to achieve with this code?

Secondly, You can get rid of some of these errors:

1. 17: error: `islowerCase' undeclared (first use this...
Forum: C++ 18 Days Ago
Replies: 16
Views: 459
Posted By amrith92
First of all, I would highly recommend you go through this (http://www.cplusplus.com/doc/tutorial/) tutorial, that'll help you brush up some basics in C++, before starting to make your own programs....
Forum: C++ Oct 19th, 2009
Replies: 8
Views: 227
Posted By amrith92
If cin.ignore(); fails, then try clearing the input stream, before accepting input. This can be done with cin.clear();.

If all your inputs are failing, then maybe try the following:

1. Clear...
Forum: C++ Oct 19th, 2009
Replies: 8
Views: 227
Posted By amrith92
Try adding a cin.ignore(); statement before each of your inputs.

See this: http://www.cplusplus.com/reference/iostream/istream/ignore/

Incidentally, its better you don't use fflush(stdin);....
Forum: C++ Oct 19th, 2009
Replies: 4
Views: 350
Posted By amrith92
You could try this:

FILE *in;
char line[1000];
char *token;
in = fopen(argv[1],"rt+");
if ( in == NULL) exit(1);
int i=0;
// Read the first line... move the file...
Forum: C++ Sep 12th, 2009
Replies: 4
Views: 346
Posted By amrith92
I'm not sure whether this is what you are looking for, but try this:


infile.seekg(0, std::ios::end);
long fileEnd = infile.tellg();
long counter = 0;
while(counter != fileEnd) {
// do...
Forum: C++ May 29th, 2009
Replies: 8
Views: 347
Posted By amrith92
Your output is expected, and here's the result (http://www93.wolframalpha.com/input/?i=sin(3.141592653589793)) of the same when I tried it on Wolfram's Online Math Engine.

Here...
Forum: C++ May 28th, 2009
Replies: 8
Views: 321
Posted By amrith92
> What am I doing wrong???

A lot! .... but nothing that you can't learn from, with a little bit of effort... Your struct contains 2 functions, both of which can directly access the other struct...
Forum: C++ May 28th, 2009
Replies: 2
Views: 854
Posted By amrith92
Wow! Good code :) beats mine by a mile... :)
Forum: C++ May 27th, 2009
Replies: 24
Views: 872
Posted By amrith92
> where the city name next to weight is should be in alphabetical order.

What exactly do you mean by this statement? What "weight" are you referring to? And by "city name should be in alphabetical...
Forum: C++ May 26th, 2009
Replies: 3
Views: 1,488
Posted By amrith92
So what do you suggest we do with it? We are not here to do your homework, just because you are too lazy to even attempt it. You have to show that you have at least made an effort to start your...
Forum: C++ May 25th, 2009
Replies: 15
Views: 621
Posted By amrith92
> cin >> can be used to enter a string (array of char) - it's perhaps the simplest input method to use.

Whoops! Sorry for the wrong info I provided! I guess I forgot about this fact because I've...
Forum: C++ May 25th, 2009
Replies: 15
Views: 621
Posted By amrith92
> just a general function that has void infront of it rather than int.

Follow this example:


#include <iostream>

using namespace std;

void MyFunc(int num)
Forum: C++ May 25th, 2009
Replies: 2
Views: 854
Posted By amrith92
My implementation of the strcmp and strncmp functions. I don't think that it is very efficient, but have managed to get both the functions' execution times to 0.01 s (At least, this is the value my...
Forum: C++ May 25th, 2009
Replies: 15
Views: 621
Posted By amrith92
Much better (compared to the other revisions)! But you still haven't fixed //< MARKER (2) from my previous post! cin will not simply accept an array of characters. You have got to use the getline...
Forum: C++ May 25th, 2009
Replies: 2
Views: 209
Posted By amrith92
This might be worth a shot: As you are going to only declare an object of the class GLCursor in your class FLGLWindow, and are not going to use its member functions directly (i.e, you are going to...
Forum: C++ May 25th, 2009
Replies: 13
Views: 668
Posted By amrith92
Did you actually go through the links I gave, and the clue I provided in my previous posts? If so, did you not understand it? and no, your code still will read your file line-by-line.

> read from...
Forum: C++ May 25th, 2009
Replies: 13
Views: 668
Posted By amrith92
I have no idea where you are going to put this, so I don't know what it will accomplish. If it is inside your while-loop, then, no it will not help at all. Anyway, this approach undermines the...
Forum: C++ May 25th, 2009
Replies: 13
Views: 668
Posted By amrith92
while (getline(iofile,line))
{
cout << line << endl;
}


Your code is on the right track. Check out the getline function's prototypes here: getline - C++ Reference...
Forum: C++ May 25th, 2009
Replies: 9
Views: 717
Posted By amrith92
I tried the same code on the same IDE (same version as well), with the same compiler, running under Windows XP, and it executed perfectly. Check the integrity of your copy of GCC, and if it isn't,...
Forum: C++ May 25th, 2009
Replies: 4
Views: 203
Posted By amrith92
See this post for more details: http://www.daniweb.com/forums/post875397.html#post875397
Forum: C++ May 24th, 2009
Replies: 15
Views: 621
Posted By amrith92
Firstly, I am not going to do the functions for you, but I'll show you where you are going wrong, and give you ideas on how to correct them. The following code is extracted from your program's case...
Showing results 1 to 40 of 115

 


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

©2003 - 2009 DaniWeb® LLC