mitrmkar 1,056 Posting Virtuoso

In addition to find(), there are also other std::string functions you may find useful, i.e.
find_first_not_of(), find_first_of(), find_last_not_of(), find_last_of(), rfind()
see http://www.cplusplus.com/reference/string/string/string.html

mitrmkar 1,056 Posting Virtuoso

Use substr(), to extract '1234', you could do:

const std::string Value10 = "Number(1234)";

const size_t start = Value10.find("(");
const size_t end = Value10.find(")");

const std::string extracted = Value10.substr(start + 1, end - start - 1);

cout << "extracted: " << extracted.c_str() << endl;

In same, fashion you can extract 'Number' once you have a valid value for 'start' .
Note that, in case string::find() does not find any match, it returns the value std::string::npos, i.e. prepare to handle that case also, when you are looking up matches to extract sub-strings.

mitrmkar 1,056 Posting Virtuoso

This is practially pretty much what Lerner said ...

std::string Value = "a,b,c,d,e,f";
istringstream is(Value);
std::string s;
std::vector<string> v;

while (getline(is, s, ','))
{
    // add item
    v.push_back(s);
}
// iterate through the vector and output each item ...
for(std::vector<string>::iterator it = v.begin(); it != v.end(); it ++)
{
    cout << *it << endl;
}
mitrmkar 1,056 Posting Virtuoso

Maybe you could use strtod() as a 'workhorse' and switch to using a double instead of integer.
See http://www.cplusplus.com/reference/clibrary/cstdlib/strtod.html
For example,

char myStr[30] = "";
while(1)
{
    cout << "Enter a decimal number: (q to quit)" << endl;
    cin.getline(myStr, 30);

    if('q' == *myStr)
    {
         break;
    }

    char * endptr = 0;
    double dd = strtod (myStr, &endptr);

    // in this particular setup, *endptr is only allowed to be newline, nothing else,
    // i.e. even an extra space trailing an otherwise valid number invalidates the input ...
    if('\n' != *endptr)
    {
 	cout << "Invalid input ..." << endl;
    }
    else 
    {
        cout << dd << endl;
    }
}
mitrmkar 1,056 Posting Virtuoso

I'd suggest to first fix the code and thereafter see if it behaves in some strange way.
You have no break statement to get out of the 'while(true)' loop, so an infinite loop should always occur.

mitrmkar 1,056 Posting Virtuoso

A couple of things,
1) you are using bitwise OR operator in

if((current[level-1]==n)[B]|[/B](current[level+1]==n)) return false;

You probably meant logical OR i.e.

if((current[level-1]==n)[B]||[/B](current[level+1]==n)) return false;

2) and then usage of 'goto', you could throw away the 'mainloop' label and inside the for() loop replace
goto mainloop;
with
break;
and just delete the third goto mainloop;

mitrmkar 1,056 Posting Virtuoso

Hope this is the right place to post

Well, maybe you actually have to turn to other forums and request for the basic OS starter code there.
By following Ancient Dragon's links above, you probably find relevant places sooner than later.

mitrmkar 1,056 Posting Virtuoso

Lerner suggested the following ...

btree b;
b.inorderWalk(b.getRoot());

i.e. using a new btree::getRoot() function to get the Node pointer needed.
Or perhaps, do a walk based on a node produced by a search() ...

mitrmkar 1,056 Posting Virtuoso

You'd probably want to use a loop for operating with user input, i.e. something like

// use an instance of btree class ...
btree tree;
// a Node pointer
Node * nodeptr = NULL;
do
{
	cout << "Please enter a menu choice:\n"
	       << "'A' - In-order Print\n"
	       << "'B' - Pre-order Print\n"
	       << "'C' - Post-order Print\n"
               << "'I' - Insert Command\n"
	       << "'S' - Search Command\n"
	       << "'D' - Delete Command\n"
	       << "'N' - Tree Minimum Command\n"
	       << "'Q' - Quit Program\n";

	cin >> menuchoice;

	switch(menuchoice)
	{
		case 'I':
			cout << "Enter a key to insert\n";
			cin >> binum;
			tree.insert(binum);
			cout << "The item inserted\n";
		break;
		case 'A':
			cout << "inorderWalk ...\n";
			tree.inorderWalk(nodeptr);
		break;
		// case 'B' ...
		default:
			break;
	}

} while('Q' != menuchoice);

If your btree class's e.g. insert() were a static function i.e.

class btree{
[B]static[/B] void btree::insert(int num);
};

then you could make a call like

btree::insert(binum);

in your code. However, since it is not, you have to have an instance of the btree class and operate with that instance instead, i.e.

btree tree;
tree.insert(binum);

Last but not least, you cannot invoke a function like this

void btree::insert(binum);

the following however is legal (and probably what you meant),

[B]([/B]void[B])[/B] btree::insert(binum);
mitrmkar 1,056 Posting Virtuoso
int Func3 ()
{    
     int Option;
     int   A = 2;   
     int B = 3;   
     double C = 2.5;         
     double D = 3.5;
     cout << " Enter your select: ";
     cin >> Option;

     if(1 == Option)
     {
          // Call func1() here
     }
     else if(2 == Option)
     {
          // Call func2() here
     }
     else
     {
          cout << "Wrong selection ...\n";
     }

     // return some value here ...
     return 0;
}
mitrmkar 1,056 Posting Virtuoso
System::Windows::Forms::DialogResult result = MessageBox::Show(this, "OK to proceed?", "A caption here ...", MessageBoxButtons::OKCancel, MessageBoxIcon::Question);

if(System::Windows::Forms::DialogResult::OK == result)
{
    // OK button
}
else 
{
   // System::Windows::Forms::DialogResult::Cancel == result
   // Cancel button
}
mitrmkar 1,056 Posting Virtuoso

If you open a command prompt (cmd.exe) and type in e.g.
gcc --version
what happens?

mitrmkar 1,056 Posting Virtuoso

Something like this ...

MessageBox::Show(this, "OK to proceed?", "A caption here ...", MessageBoxButtons::OKCancel, MessageBoxIcon::Question);
mitrmkar 1,056 Posting Virtuoso

Your main() is not returning an int, maybe nothing at all or something else, so ..

int main(int argc, char * argv[])
{
    // your code here

    // return some integer value, in this case zero ...
    return 0;
}
mitrmkar 1,056 Posting Virtuoso

What do you mean by 'crashing'?
Is it so that VirtualAlloc returns NULL and you are still using the pBuffer?
Or something else?

mitrmkar 1,056 Posting Virtuoso

First things first, I second to WaltP, really format your code to make it readable. Now it's close to unreadable.
Arrays are zero-indexed .. hence both of your string arrays now have an unused index 0, in other words, you should do with smaller (by one) string arrays.

string squares[] = {"1","2","3","4","5","6","7","8","9"};
instead of 
string squares[] = {"0", "1","2","3","4","5","6","7","8","9"};

You could throw away the squares array, since you only use it to validate that user's move is within the accepted bounds (I haven't seen a similar construct before). You might do better by getting an integral value instead of strMove (and throwing away the for loop too).
Using arrays of std::string is a bit heavy-duty solution, a more simple type as char would serve as well.

mitrmkar 1,056 Posting Virtuoso

You are having a following kind of construct, where the compiler does not know what Sort actually is inside the main() function.

#include <stdlib.h>
// Declaration of Sort commented out
// int Sort(const void *p, const void *p2);
typedef struct 
{
  int a;
} MYSTRUCT;
MYSTRUCT items[2];
int main(int argc, char* argv[])
{
	// Compiler complains "'Sort' : undeclared identifier"
	// (rightfully so, because declaration of Sort is commented out, above)
	qsort((void *)items, 2, sizeof(MYSTRUCT), Sort);
	return 0;
}

int Sort(const void *p, const void *p2)
{
	return 0;
}

So you need to declare your Sort() function before the function in which you call qsort().

mitrmkar 1,056 Posting Virtuoso

>> you can edit your first post.
It seems that once posted, a post remains editable for some short period of time and then enters a non-editable mode. Is there any way, for one to edit one's own post regardless of how long it has been on the forum?

By the way, what is 'bumping' in this context?

mitrmkar 1,056 Posting Virtuoso

Remove the

int Get_Number (int x);

that is there on line 22.

mitrmkar 1,056 Posting Virtuoso

Change:
qsort((void*)word, wcount, sizeof(WORD), int(*Sort)(const void*, const void*));
to
qsort((void*)word, wcount, sizeof(WORD), Sort);

mitrmkar 1,056 Posting Virtuoso

Umm .. that should be easy to solve, I take that you have also declared the Parse() function, so the Sort() function should be declared in same fashion.

mitrmkar 1,056 Posting Virtuoso
int Sort(const void *l, const void *r)
{
        WORD *left = (WORD *) l;
        WORD *right = (WORD *) r;
        int n;

        if(left->count == right->count){
                n = strcmp(left->count, right->count);
                return n;
        } if(left->count > right->count){
                return 1;
        } else {
                return -1;
        }
}

Your sort function works right out-of-the box, after you have changed:

n = strcmp(left->count, right->count);

to

n = strcmp(left->word, right->word);

Only one function is incorporated there regarding the whole function of the program, and that's where I am appending all the processes.

OK .. then have to insert the qsort() call in that function, just be sure that all the input has been parsed before you call qsort().

mitrmkar 1,056 Posting Virtuoso

Because pl and pr both are pointers to void, you cannot use them as such to access the data they point to. Hence you need to type cast them properly before usage.
The only correct choice here is to cast them to (WORD *), nothing else will do.

mitrmkar 1,056 Posting Virtuoso

If you have:

WORD * pLeft = (WORD *) pl;

then you use pLeft->count and pLeft->word
and the same way
pRight->count and pRight->word

So you can e.g. compare the words by calling:

strcmp(pLeft->word, pRight->word)

Remember that in the sort function, you only access two individual elements of your word[] array and compare just those two elements (pLeft and pRight) hence telling qsort() how to order these elements. You need/should/must not access your word[] array at all from within your sort function.

You can output the elements inside your sort function by having e.g.

printf("mySort: left argument (%d/%s) - right argument (%d/%s)\n", pLeft->count, pLeft->word, pRight->count, pRight->word);

just to see what gets into your sort function.

>> Are those temporary variables?
Yes, they are just temporary pointers providing access to the actual data.
Maybe names like LeftElemPtr and RightElemPtr would be more descriptive.

mitrmkar 1,056 Posting Virtuoso

I'd rather use something like

if(MAXWORDS == wcount)
{
printf("Error: maximum number of words (%d) already used. Aborting ...\n", MAXWORDS);
exit(1);
}

In general, whenever your programs fail/exit due to some error condition, try to be informative, so that the user gets some insight on what went wrong (they may be able do something to remedy the situation and retry).

mitrmkar 1,056 Posting Virtuoso

Just remembered that I did not answer your question:

"Regarding the checking if the wcount is still less than the MAXWORDS, what output should I make if ever the wcount is still right or vice versa?"

There is no sense in continuing the program if the upper limit has been reached (because there are no means to dynamically grow the word[] array).
So, maybe just output a descriptive error message in that case and exit the program. You can use the exit() function for that purpose.

mitrmkar 1,056 Posting Virtuoso

First of all, your sort function (you need only one of them actually), has to be declared as

int mySort(const void * pl, const void * pr)

otherwise it will not compile/work.

The qsort() calls your sort function (which is the brains of the sort) as many times as it deems to be necessary to have your word[] array fully sorted.
You don't have to care about how many times that is, just focus on the fact, that every time your sort function is called (by qsort()), you effectively receive two pointers to a structure of type WORD (the left-hand side and the right-hand-side).

Now, if the left-hand side should be ordered before the right-hand side, return a negative value,
else, if it is vice versa, return a positive value else return zero (i.e. the elements are equal, having same freq count and the strings being equal too). Notice that the semantics of the return value is the same as with strcmp(), which you can use in your sort function.

So, in your one and only sort function, first compare the frequency, if that's equal, let strcmp() do the comparison, else figure out whether to return positive or negative value.

This is the basic construct of your sort function

int mySort(const void * pl, const void * pr)
{
     // Get the pointers to the two WORD structs and compare
     WORD * pLeft = (WORD *) pl;
     WORD * pRight = (WORD …
mitrmkar 1,056 Posting Virtuoso

<< in what order this qsort sorts a certain list?
You don't actually have to think about it, leave it as an internal of qsort().
Just be sure that your own sort function works as planned and provide valid arguments to the qsort() call.

Maybe I didn't understand you right ... so the final order of the elements in your array after qsort(), is practically dictated by your own sort function.

mitrmkar 1,056 Posting Virtuoso

Well it is getting closer ... but there are errors, I try to explain.

void Insert(char *token)
{
        int i, loop;

        // Array indexes are zero-based, hence you start from 0, 
        // and loop must be less than wcount, so ...
        for(loop = 0; loop < wcount; loop++)
        {
                i = strcmp(token, word[loop].word);
                if( i == 0 ) {
                        word[loop].count++;
                        return;  // This is perfectly OK
                }
                else{
                // This else part was completely wrong ...
                // Just think about it, if token is not at index pointed 
                // to by 'loop', it may very well be at the next index or 
                // somewhere after that ...
                // so, you have to go through all the existing entries you
                //  currently have, i.e. you must do nothing within this else 
                // block here. 
                }
        }

        // So, we are out of the loop here ...
        // Now that you've looped the whole table without finding a match, you
        // insert a new entry 

        word[wcount].word = token;
        cgiHtmlEscape(word[wcount].word);
        fprintf(cgiOut, " , ");
        // word[wcount].count is a number, so you do not need to/
        // cannot HTML-escape it
        // cgiHtmlEscape(word[wcount].count);
        // you can write it to file as follows, if you want to
        fprintf(cgiOut, "%d", word[wcount].count);

        wcount++;
}
mitrmkar 1,056 Posting Virtuoso

Sorry to say, but no. The loop should be like;

void Insert(char *token)
{

for(i = 0; i < Count_Of_Words_Inserted_To_Table; i++)
{
     // This comparison is OK
     n = CompareStr(token, word[i].word);
     if(n == 0)
     {
           // This is also OK, increment the count
           word[i].count++;
           // but RETURN STRAIGHT AWAY ... 
           [B]return;[/B]
        }
}

// Now, because we are here, it means one thing only,
// which is that the token was not found in the table.
// (we looped the whole table through)
// So, just insert the token to the table

word[Count_Of_Words_Inserted_To_Table].word = token;

// and keep track of the count of words in the table
Count_Of_Words_Inserted_To_Table = Count_Of_Words_Inserted_To_Table + 1;
}

I take that the variable 'int loop' originates from your Parse() function, please drop that variable altogether - you do not need it and must not use it in Insert().
Count_Of_Words_Inserted_To_Table is equal to the WordCount variable I've used in the previous postings. (I.e. a global variable accompanying your word[] array.)

And remember to check that Count_Of_Words_Inserted_To_Table will not exceed the size of your word[] array! If it does, you will be enjoying a program crash.

mitrmkar 1,056 Posting Virtuoso

Oh mine, you still have a local variable WORD word inside the function ... that just won't work.
void Insert(char *token, int loop)
{
int i, n;
WORD word;
}

You must have an array of WORD structures declared outside your functions. i.e.

#include <stdio.h>
#include <string.h>
#define MAX_WORDS 1000
WORD word[MAX_WORDS] = {0}; // The one and only WORD table that you declare and use
unsigned WordCount = 0;
int main(int argc, char * argv[])
{
     // the program code here ...
}

You can also replace the CompareStr() function with strcmp().
Based on the previous postings, I'd say that your input string (which you parse) IS terminated with a NULL character, so don't worry about that.

mitrmkar 1,056 Posting Virtuoso

One more question about this: What does the 'buffer++' do? If I apply this function, will it directly convert each word to lowercase? Thanks.

buffer++ increments the pointer (i.e. buffer) to point to the next character.

The condition "while(*buffer)" could be written as
while('\0' != *buffer)
i.e. loop until you encounter the terminating NULL character in the string.
(If the string is NOT terminated with a NULL character, then the loop is good at producing a nice program crash sooner or later.)

It directly converts each character to lowercase.

mitrmkar 1,056 Posting Virtuoso

Meaning, I have to place some more codes/incorporate some more functions in order to make sure that no similar words might have a double assignment. Am I getting it right?

Yes, there are two todo:s in the above Insert() function, which you have to do.
The check for exceeding the maximum number of words used in that function is also essential.

mitrmkar 1,056 Posting Virtuoso
void Insert(char *token, int loop)
{
        // This won't work at all <=> a single, non-static 
        // local WORD structure !!!
        [B]WORD word;[/B]
        word[loop].word = token;
        cgiHtmlEscape(word[loop].word);
}

Please take a closer look at my previous post.
Notice that you only want to insert a word which does not pre-exist in the table.
This implies that you have to search the existing entries and operate on the basis of that search.

mitrmkar 1,056 Posting Virtuoso

And correct me if I'm wrong, as far as I know strings cannot be taken as separate characters to be manipulated by any command in the ctype.h library [where tolower is].

You can write yourself a routine that converts the input to lower case character by character, e.g. like;

void strlower(char * buffer)
{
	while(*buffer)
	{
		*buffer = tolower(*buffer);
		buffer ++;
	}
}

About the Parse() function, it seems to be OK. I take that the cgiHtmlEscape(token) does not modify the input buffer, so using it is OK, too. (Based on what I found in http://www.koders.com/c/fid273B6AAF9CA572AEAC4D91193A4ED0052119532E.aspx?s=cgiHtmlEscape#L2465)

But when it comes to the words table + the Insert() function, there you are going wrong.

#define MAXWORDS 100
size_t nWordsUsed[B] = 0[/B]; // Initialize to zero!
// I would change the typedef to ...
typedef struct
{
   char *word;
    int wfreq;
} WORD;
// Then ... the table that you will be using ([B]outside any functions[/B]),
// also zero-initialized.
WORD table[MAXWORDS] = {0};

void Insert (char *token)
{
    // We have a valid token here, which may or may not be already in table,
    // loop through the existing entries, if any, and check whether to insert or
    // increment the freq count
    for(unsigned nn = 0; nn < nWordsUsed; nn ++)
    {
       // assuming token is in lower case
       if(0 == strcmp(token, table[nn].word))
       {
            // todo: increment the freq count and [B]return[/B] ...
       }
    }

     // no match, a new word into the table ...

     // …
mitrmkar 1,056 Posting Virtuoso

I'll get back to this in 15 mins or so ...

mitrmkar 1,056 Posting Virtuoso

>> ... the result is a single string.
I suppose you are able to modify that 'single string'? If so, you should be able to apply tolower() to the whole string before parsing anything (I'm not familiar with cgi lib (sorry)).

>> Then I was able to parse it into words [which are also strings]
=> good.
So I take that you effectively modify the input string by replacing non-alphas with a '\0' character when you parse (?).
Note! When you iterate over the string parsing it, be sure not to go past the input string (I take that it is a C-style string, i.e. terminated by a '\0' character).

It might prove very helpful if you post the code which is doing the word insertions to the table.
Showing also how you have actually declared the table.

mitrmkar 1,056 Posting Virtuoso

The parsed tokens are in string form,is there any way that I could manipulate them as arrays? I'm referring to the comparing of each character so I can do things like : making them all in lowercase,

If you read the whole input into one block of dynamically allocated memory, regarding lower case conversion, do it before you parse anything by applying tolower() on the whole input you have. So, you do not have to worry about character case after that anymore.

comparing them with each other, etc.

If you store the pointers to a table of the Entry structs, you can iterate over the table and compare the individual entries you have stored e.g.

for(unsigned nn = 0; nn < nWordsUsed; ++ nn)
{
   if(0 == strcmp(table[nn]._pWord, someString))
   {
        // someString is already in the table
        ....
   }
}

Probably that was what you were wondering about (I hope).
Another place you need to use strcmp(), is your sort function (assuming that you will use qsort()).

mitrmkar 1,056 Posting Virtuoso

Since I don't know what the function is supposed to do, I cannot offer much advise. However, if you plan to change the values of the parameters passed into the function, you need to pass the parameters by reference, instead of by value. I.e.
public char CheckDir(int & row, int & col, int & selectedX, int & selectedY);

Ancient Dragon commented: The OP doesn't know what he wants to do either :) +24
mitrmkar 1,056 Posting Virtuoso

Compilers do not insist on using #ifndef.

mitrmkar 1,056 Posting Virtuoso

I replaced
Point Vector::GetPoint()
with
Point GetPoint()
is that not a good idea?

Hmm, a hard question for me to answer, it depends ... so to speak. But if your needs have remained unchanged, i.e. "I have a class Vector that needs to have a function that returns type Point, and a class Point that needs to have a function that returns type Vector.", you should stick with the construct described. Otherwise, you are free to find another solution that works for you the best.

"#ifndef statements" should naturally be involved (I was just illustrating the construct with forward declarations used as you needed, hence no #ifndef statements).

mitrmkar 1,056 Posting Virtuoso

Trivia: using %lf with printf is undefined behavior in C90, a common nonstandard extension, and standardized in the uncommonly-implemented C99 as ignoring the l.

A good piece of trivia that one, thanks. Just wonder how come it has been so popular, apparently in practice, that is has been "standardized in the uncommonly-implemented C99 as ignoring the l"... hmmm.

mitrmkar 1,056 Posting Virtuoso

Also the second operand really must be changed from
while(strcmp(pt->next, ' ')!=0)
to
while(strcmp(pt->next, " ")!=0)
because C-compiler treats ' ' as an integer and strcmp() does not expect an integer.

mitrmkar 1,056 Posting Virtuoso

>> can you give me a tip regarding memory allocations during the parsing part?
I would suggest that you read the input from the file in one fread() function call. I.e. read the file in at once - for that you have to dynamically allocate enough memory.
After you have allocated the needed memory, you do not have to use any memory allocation after that. This can be achieved if
a) your Parse() function modifies the input buffer by replacing non-alpha's with a null character
b) your Insert() function just sets the word pointer to point to the allocated memory. So you don't need to do anything like "Entry._pWord = (char*)malloc(...)", instead just set the _pWord to point to the word in the input buffer.

Trying to make this a bit clearer .. say that you have a non-constant string
char MyInputData[] = "This is a test string";
No you parse the whole string,
Parse(MyInputData)
which renders the string to:
"This0is0a0test0string"
i.e. 0==NULL character. The Entry table would contain 5 entries pointing to the MyInputData string, e.g. table[0]._pWord == MyInputData and table[1]._pWord == &MyInputData[5] etc.
Finally, when you are done, remember to free() the memory you have allocated.

mitrmkar 1,056 Posting Virtuoso

did the grandtotal, but if I change the %ds to %lf then it adds decimal places to the quantity. What if I change the whole ticketquan part to an integer instead? Would there be a way for me to convert the integer to a double so I can multiply it with the price?

ticketquan surely can be an integer (and is more natural in that way), so the answer is yes.

mitrmkar 1,056 Posting Virtuoso

Try following

[B]// Point.h[/B]
class Vector;
class Point
{
public:
	Vector GetVector();
};
//////////////////////////////////////////
[B]// Point.cpp[/B]
#include "point.h"
#include "vector.h"
Vector Point::GetVector()
{
    Vector v;
    return v;
}
//////////////////////////////////////////
[B]// Program.cpp[/B]
#include <iostream>
#include "Point.h"
#include "Vector.h"
using namespace std;
int main()
{
    Point P;
    Vector V;
    return 0;
}

Construct the vector.h/cpp in the same fashion.

mitrmkar 1,056 Posting Virtuoso

What is the format of the input file (i.e. what fields and in which order)?

mitrmkar 1,056 Posting Virtuoso

Here is the version I used (and please go through the %d's and change to %lf where-ever you output a double using printf())

void heading(void);
void quanerror(double min);
void costerror(double min);
double getfloat(char prompt[], double min);
double getdouble(char prompt[], double min);
double total(double ticketquan, double ticketcost);
void show(double ticketquan, double ticketcost, double tickettotal, double grandtotal);
int contyn(char msg[]);

int main()
{
	double quanmin, ticketquan, ticketcost, tickettotal, costmin, grandtotal;
	char choice;
	quanmin = 0;
	costmin = 5;
	[B]grandtotal = 0;[/B]

	do
	{
	heading();
	ticketquan = getdouble("quantity", quanmin);
	ticketcost = getfloat("price", costmin);
	tickettotal= total(ticketquan, ticketcost);
	grandtotal+= tickettotal;
[B]	show(ticketquan, ticketcost, tickettotal, grandtotal);
	choice  = contyn("\nWould you like to purchase more raffle tickets?");	
[/B]	}
	while (choice == 'y' || choice == 'Y');

        return 0;
}
/* ================================================================ */

void heading()
{
	system("cls");  // Linux/Unix use: system("clear");
	printf("WELCOME TO THE RAFFLE!\n");
	return;
}
/* ================================================================ */
double getdouble(char item[], double min)
{
   int err;
   double ticketquan;
   min = 0;
   do
   {
   printf("\nEnter a ticket %s greater than or equal to [B]%lf[/B]: ", item, min);
   //scanf("%d%*c", &ticketquan);
   scanf("%lf%*c", &ticketquan);
   err = (ticketquan < min);
   if (err) quanerror(min);
   }
   while (err);
   return (ticketquan);
}
/* ================================================================ */
double getfloat(char item[], double min)
{
   int err;
   double ticketcost;
   min = 5;

   do
   {
   printf("\nEnter a ticket %s greater than or equal to %.2lf: ", item, min);
   scanf("%lf%*c", &ticketcost);
   err = (ticketcost < min);
   if (err) quanerror(min);
   }
   while (err);
   return (ticketcost);
}
/* ================================================================ */
void quanerror(double min)
{
	printf("\nOut of range.  Enter a quantity …
mitrmkar 1,056 Posting Virtuoso

>> Now I have another problem...
I suspect that your code goes something like this;

[B]{[/B]  // <- start of a block (for some reason)
    ofstream fout;
    ... code ...
[B]}[/B]  // <- end of the block ('fout' does not exist anymore at this point)
... code ...
// Report summary data for all customers
   total_revenue = total_water_revenue + total_electric_revenue + total_gas_revenue;
   // trying to use non-existing 'fout' here
   fout << "Number of Customers:       " << num_customers << endl;
... code ...
mitrmkar 1,056 Posting Virtuoso

I tested it with a couple of modifications, got the following output:

Enter a ticket quantity greater than or equal to 0: 5
Enter a ticket price greater than or equal to 5.00: 8

Amount of tickets: 5.000000
Price per ticket : 8.00
Total amount due : 40.00
Grand total of all purchases: 40.00

...

#1 in the main() function, initialize "grandtotal=0"
#2 Switch order of the two lines to be like below
show(ticketquan, ticketcost, tickettotal, grandtotal);
choice = contyn("\nWould you like to purchase more raffle tickets?");