Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The while statement on line 19 is incorrect -- you don't need numOfInput. To read the entire file the while statement should be constructed like this:

while( inStream>>deweyDecimal )
{
   // blabla

}

But that will only read one word. If each line in the file contains more than one word then you will want to use getline()

while( getline(inStream, deweyDecimal) )
{
   // blabla

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>operand!='+' || operand!='-';

Use && operator instead of ||. Read the statement aloud to yourself -- "do while operand not + and while operand not -.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 14 and 17 are just showing you two different ways to do the exact same thing.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm sorry I wasn't clear. I'm not sure what you mean by the "OP".
OP = Original Poster, in otherwids, you.

>>error C2065: 'c_file' : undeclared identifier
That means you failed to declare a variable called c_file, so the compiler has no idea what you are talking about on that line.

line 64: remove the space after c:

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>You have to include windows.h,

No you don't. including windows.h will make a simple console program carray around a lot of useless and unnecessary bagage. Just include cstdlib (as previously mentioned) or stdlib.h.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if ( 'a'=!'e' || 'a'=!'d' || 'a'=!'E' || 'a'=!'D')

remove the quotes around variable a if ( a=!'e' || a=!'d' || a=!'E' || a=!'D') and not equal is !=

You want to use && and operator, not or operator. Using or in that statement will cause it to always return true regardless of the value of a.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>1- read files from the directory, avoiding sub-directories (along w/ _chdir)

That means to use directory functions to get the names of all the files in a directory. How to do that will depend on what operating system you are using.

  1. MS-Windows: FindFirstFile() and FindNextFile()
  2. *nix: Opendir() and ReadDir()

Google for those functions and you will find out how to use them. I have posted example programs for both operating systems here in Code Snippets, but they are probabgly more advanced than what you can handle at the moment.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

make sure to link with Shell32.lib

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ShellExecute() is declared in Shellapi.h, not windows.h

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

tchar.h

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try the same program with a more modern compiler, such as Code::Blocks or VC++ 2010 Express, both free. The problem might be that old compiler you are trying to use on MS-Windows operating system.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program seems to be doing it correctly. But I don't see where you declared variable named sum.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>My friend needs a program that will:

That's nice -- now when are you going to write it for him? We certainly will not without a lot of $$$$.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. you don't need that while loop that starts on line 5 so just delete it2.

2. The for loop sould cout from 0 to < size, not <= size-1. If the value of size is 5, then you want it to count 0, 1, 2, 3 and 4.

3. Use a do loop to verify the value of rainfall >= 0, something like this

do {
   ask question
   input value of rainfall
} while( rainfall < 0);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you mean esp not ebx. ebx is a general purpose register which does not need to be restored.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try using if( inHandle.is_open() ) The problem might also be that the file does not exist in the current working directory.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Which tells scanf() to continue taking input until you hit the enter key

And which is a very good reson not to use it. It's no safer than gets(). Both will let you happly type as many keys as you want, scribbling overflow characters all over the program's memory, causing crashes and sig faults.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Any salary difference will be neglible. You need to talk to a school couseler at the college you want to attend to find out what courses are required for each of those degrees. A degree in CS will probably require more math than the degree in IT.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Use fgets() if you want to put spaces in the text. The side affect of fgets() is that it puts '\n' at the end of the string, if it will fit.

printf("Dog's name?:");
fgets(str2, sizeof(str2), stdin);
// now remove the '\n' from the string
if( str2[strlen(str2)-1] == '\n')
   str2[strlen(str2)-1] = '\0';
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why you dont try fread() and fwrite() function which are capable of reading and whole structure at once example of fwrite()

Because he's only reading words from some text file, not the structure.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The structure is declared incorrectly -- wrd needs to be a pointer so that it can be allocated at runtime.

struct word {
    int count; // counter to use the word's occurrence
    char* wrd;
}*wordptr[50];

line 21: >>wordptr[position] = (struct word *) malloc(sizeof(struct word));

You need to do two things here
1. allocate an instance of the structure because the array is just an array of pointers. All the pointers have to be allocated memory before they can be used.
2. Allocate memory for wrd within the structure.

wordptr[position] = malloc(sizeof(struct word));
wordptr[position]->wrd = malloc( strlen(temp)+1 );
// now you can copy temp into wrd
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is the error??? Please don't make us guess.

You don't need a loop just to get the first letter of the string, so you can just delete lines 17, 18 and 29. cout<<lastName <<", " <<firstName<<" " <<middleName[0] <<endl;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Those pictures are called avatars, and are available to anyone. Set yours in the CONTROL PANEL link found at the top of each DaniWeb page. Everyone also have titles, but certain members can create their own title (admins, past and current mods, and those who donate their money to DaniWeb, called Sponsors)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That link works ok, but it does not sole the OPs question.

@valkyrie: You will want to ask the question(s) in another thead so that the main thread can cancel it out when the time has expired. Something on this order (assuming MS-Windows operating system). Note that you don't have to use clock() at all.

int questionThread(void* ptr)
{
   // display and ask a question here
}

int main()
{
   for each question
   {
     create thread using questionThread()
     wait for thread to finish normally or timeout expires.  WaitForSingleObject() will do that for you.
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its not considered an error -- just an option to let the compiler optimize out unused functions and data.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your link appears to be broken -- I get an IE error that the page can not be displayed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, actually the Microsoft linkers will delete functions or data that are never called or referenced, or so their documentation tells us.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't need that loop at all -- just set up al, eax then call rep scasb to search for the string length

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> if(foo())

But Hello World should be displayed regardless of the return value of foo(), and the || 1 causes that. So you can't just toss out that or condition.

Fbody commented: Nice catch. :) +5
VernonDozier commented: Yep, good catch. +13
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Except that AC is actually 29 (after Z comes AA, AB, AC, etc.), so for AA to be 27,
Oh yes -- of course, duuuuh!

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Have you studied this tutorial?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i fixed the size of problem by changing it to
int arraysize = sizeof(sales)/sizeof(int) ;
based on info i found online
also fixed endl and cout problems
other problems still persistent
thanks for all your responses by the way

Wrong -- wrong -- wrong. Didn't you read my previous post about sizeof and pointers???? sizeof(sales) will always be 4 because variable named sales is a pointer, not an array. If you want your program to be wrong then go ahead and leave it the way you have it. I'm not going to mention this to you again. Just do it however you want to because its your funeral, not mine.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is chapter and verse from c++ standards ISO/IEC 14882, Programming language – C++ dated 2008-10-09. Note that 3.6.1.2 states main() shall not be overloaded.

Yes, I am well aware that this is the C forum, not C++. I don't have a copy of the C standards but I'm certain it contains the same or similar verbage.

3.6.1 Main function [basic.start.main]
1 A program shall contain a global function called main, which is the designated start of the program. It
is implementation-defined whether a program in a freestanding environment is required to define a main
function. [ Note: in a freestanding environment, start-up and termination is implementation-defined; startup
contains the execution of constructors for objects of namespace scope with static storage duration;
termination contains the execution of destructors for objects with static storage duration. —end note ]
2 An implementation shall not predefine the main function. This function shall not be overloaded. It shall
have a return type of type int, but otherwise its type is implementation-defined. All implementations shall
allow both of the following definitions of main:
3 The function main shall not be used (3.2) within a program. The linkage (3.5) of main is implementationdefined.
A program that declares main to be inline or static is ill-formed. The name main is not otherwise
reserved.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What are you trying to do with the Salary method of SalesReport? You want to modify the array passed as a parameter? Or you want to compute a total salary from the sales received? If you want to modify the array passed as a parameter, you're doing it with the code you already have...

Maybe you want to do this instead:

The code you posted is incorrect. See my previous post about why sizeof does not return the number of elements in the array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You may have to do a lot of recoding. Read this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

while statements are incorrect.

while( InBoundData>>type )
{   
  InBoundData>>speed>>source>>destination>>
     distance>>depart>>reach>>hour>>ticketprice;
  cout<<type<<"  "<<speed<<" "<<setw(9)<<source<<" "<<setw(3)
     <<destination<<" "<<setw(5)<<distance<<" "<<setw(5)<<depart<<" "<<setw(2)
     <<reach<<" "<<setw(8)<<hour<<" "<<setw(10)<<ticketprice<<endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 15 of report.cpp: That line doesn't do what you want it to do. sizeof(any pointer) is always the same. Arrays are always passed to functions by pointer even if you declare it like an array. Since this is a c++ program you should use vector<int> sales, then that function can easily get the number of elements in the array.

SalesReport::SalesReport(std::vector<int>& sales)
{
	Salary(sales);
	DisplaySalary(sales);
}
int SalesReport::Salary(std::vector<int>& sales)
{
    int arraysize = sales.size();
    int i = 0;
    while (i <= arraysize)
    {
          sales[i] = (sales[i]* .09) + 200;
          i++;
    }
    
   return sales;
}

As for your specific problems, please tell us the line numbers that are causing the errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On PCs there was a speed difference some 30 years ago, but hardware technology has advanced to where there is no longer a speed difference. Here is just one of many threads you can find on the subject.

It is my impression that FORTRAN may be a better language to use than c or c++ for heavy numerical processing. However I havn't used FORTRAN in decades, so that statement may or may no longer be valid.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

With VC++ 2010 look in <cctype> and you will find that it's in std namespace, just as Narue said it is. _STD_BEGIN is defined as #define _STD_BEGIN namespace std { in yvals.h

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No -- reverse the order of lines 5 and 6. As it is, line 6 will never get executed because the function exits on line 5.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

move all those global variables on line 5 down below line 8 so that they are inside the function. Globals are bad -- avoid them when ever possible.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Accessing databases can be quite complicated. There are a lot of tutorials about ODBC, the oldest and most widely used way to do it. Here are a few tutorials for you to study. There are several other ways to do it, depending on the database and operating system, but ODBC is the most common and supported by all SQL-compliant databases.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You mean how to convert column A to column 1? Yes, that can be easily done. The quickest way would be to take the single-letter column value and subtract 'A'. So if the column name is 'C', then it would be 'C' - 'A' + 1, which is 67 - 67 + 1 = 3 (see any ascii table). If you have two-digit column name such as AA then you have to do the substraction for each of the individual letters. So that 'AC' becomes (('A' - 'A' + 1) * 10) + ('C' - 'A' + 1) which is 10 + 3 = 13

Now put all that in a loop and you can do it for any number of columns with any number of digits in the column name.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. No
2. Yes, providing you reallocate the memory before attempting to use it. .

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to flush the input keyboard buffer before asking for choice. When you enter a number you also have to press <Enter> key -- that key is not removed from the keyboard buffer. so the next request for a char will get the '\n' that's already in the keyboard buffer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are no standard C functions that will convert a string that contains commas as you posted. You will have to write your own custom function to do that. Same with outputting.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 140: The value of Area is undefined because it has not been initialized to anything. I expect what you meant to say is Area = paint_area / COVERAGE.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want to convert it yourself then amnt=money*10+1; is incorrect. Should be something like below -- you can not assume the string contains all numeric digits.

while( isdigit(money[i]) )
{
    amnt = (amt*10) + money[i] - '0';
    ++i;
}

Now do something similar for the cents. You might have to use another variable for this, then put the two together.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what's that demand stuff??? You start demanding something of us and you will just get ignored.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Sorry, you are all wrong. You may have as many mains as you want, provided they are all static (except one, of course).

Nope. The only way to do that is to put each of the static functions in different *.c files and not in the same *.c file as non-static main()