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

When you pull the rug out from under an executing program there is no guarentee that the operating system can kill the process cleanly. Using that taskkill.exe should be a last resort.

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

line 92: isdigit is a macro that returns a bool value (true or false, 1 or 0) You can not compare it with a value as you have tried to do in that line.

Other errors I found are just careless errors, such as misspelled function names. Check the error messages better and you will be able to correct them.

ifstream and ofstream objects have to be passed by reference, not by value, like this line: void load(ifstream& infile); But that is also going to get you into deep trouble because the streams were already opened in main() and your program is trying to open them again in load() and save(). Do that is just one of the two places, but not both. Since the streams declared in main() are not used for anything just don't pass any parameters to load() and save(), and declare the stream objects in those functions.

Clinton Portis commented: muy bien +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your example is wrong. What about the two Ns in Bunny and the s's in Mississippi?

DID THE BUNY GET THE MISISIPI MAPS FROM B

One problem with that is there is no way to recreate the original sentence. In any event, you will have to show is what you have attempted, such as post some code or pseudo code.

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

seriously, who cares to believe if a word exist or not.

English teachers, and others who want to express themselves correctly so that other people can understand them. Its similar to using leek speak here on DaniWeb forums -- forbidden.

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

All you have to do is swap the data item of the two nodes -- just like you would swap any two integers.

And please use code tags the next time you post code so that people can read it.

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

Well, yes he is right about that. This is an employer's market, meaning that programmer's today are a dime a dozen. If you don't know how to market yourself you will be flipping hamburgers ar McDonalds or bussing tables at restaurants for many years. That deree you get from college is no guarentee you will get gainful employment in your chosen field of study. I know people with Masters and Ph.D. who are out of work.

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

I assume you already know enough assembly language to at least start that project. Teachers don't just toss a project like that at on the first day of class. So, get started and post what you have done. You will probably want to write some pseudo code first so that you understand the problem and possible solutions better.

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

It took several years before I could write C code without use of a very good reference book next to my computer. I was constantly looking up functions and their parameters just to make sure I was coding it correctly. Then I learned to use debuggers and how to use them to quickly figure out problems with the code I wrote.

I don't see that effort much here at DaniWeb. Many students don't want to put in the time and effort needed to learn a language. Instead they want other people to spoon-feed the answers.

Another problem I see here occasionally is someone who doesn't understand the answers they are given. They ask a question, one or two people offer correct solutions, but the OP asks the same question again because they didn't understand the answers given.

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

students include kids from ages 4 to 104. Anyone attending a school is a student. Strictly speaking, other people are often students as well, such as those attending one-time technical training courses.

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

Sounds like you have to write a C program, not a C++ program. In that case I would use strtok() to split the line.

#include <stdio.h>
#include <string.h>

int main()
{
   char line[] = "shunt train2.in 2";
   char *verb, *filename, *ptr;
   int num;
   verb = strtok(line," ");
   filename = strtok(NULL," ");
   ptr = strtok(NULL," ");
   printf("%s %s %s\n", verb,filename,ptr);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's bad coding to do what openRecords() is doing. The ifstream object should be declared in main then passed by reference to OpenRecord()

int main ()
{
	//Title
	cout << " Employee sales records.\n" << endl;

	//Get the file stream or quit if the records file is not found. 
	ifstream fileStream;
         OpenRecords(fileStream);
	
}


void OpenRecords(ifstream& CheckFileStream)
{
	// Make sure the records file exists before running the program
	cout << "\n Welcome, performing record check..." << endl; 
	// Create a pointer to the filename 
	const char* FilePntr = "SalesRecords.txt";
	// Attempt to open the file, if good return pointer of open file stream else report error and exit.
	CheckFileStream.open(FilePntr);
	if (!CheckFileStream.is_open()) // <<<<<<<<<
	{
		cout << "\n Record file found."<<endl;
	}
	else // Inform of file not found/or empty file and exit the program
	{
		cout << "\n RECORD FILE NOT FOUND!\nTHIS PROGRAM WILL NOW EXIT\n"<<endl;
		system("PAUSE");
		exit(1); // <<<<<< 
	}

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

Sure, why not?? There have been a lot of theories about where we came from. Mars is as good an explanation as any other because they are all nothing more than guesses. No physical proof exists anywhere in the universe about how life in Earth got started.

Even if they find DNA similarities between Earth and Mars it doesn't mean a damn thing because the same DNA similarities could exist between all planets everywhere in the universe. We don't know, and we probably will never know.

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

If you can't use c++ objects then use FILE* and call fgets() in a loop until end-of-file is reached, counting the number of iterations of the loop. When done, you will have the number of lines in the file.

codeyy commented: thanks. +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes I know you wasn't referring to me. I'm not old.:) People's ability to do outdoor sports start to fail about age 30. Men are over the hill by that age, but women are just getting started.

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

That really has nothing to do with getting old. I know young people who are bed ridden due to failing health or illness.

jingda commented: Inquisitive, good and positive learning attitute. Continue learning +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, but be careful not to overflow the integers. check limits.h to see the maximum value that can be stored in an integer with your compiler.

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

You need to check the laws of the country in which you are located. Probably ask a lawyer or solicitor.

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

I already mentioned one solution. using doubles just introduces inprecision. Maybe something like this:

// this might work if all you are interested in is one decimal place.  
int start; 
int stop = (int)(ust*10.0);
for(start = (int)(alt*10.0); start <= stop; start++)
{

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

What you are asking is how to reformat a simple text file -- csv files are just text files. Read the file one line at a time, make apprporpate changes then write the new line back out to a different file. If the file is small enough you could read the whole file into a vector or array of strings, make changes to them, then re-write the file with the new data. Thes are all standard file i/o functions and if you know how to read and write text files then you can easily read/write that csv file.

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

>>When you retired, you could do whatever thing you want

Yea -- right. And if you believe that I have some shares in the Golden Gate Bridge that I'll gladly sell you.

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

No you haven't. Windows uses Sleep() not sleep() (capital S). Also, *nix sleep() parameter is in seconds -- MS-Windows Sleep() parameter is milliseconds.

TailsTheFox commented: Actually answered the question! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think wait() is an old Turbo C function.

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

What compiler are you using? I just successfully compiled/linked using vc++ 2010 Express. First created an empty win32 project, added a *.cpp file and copied your code into it. Compiler and linked without any warnings or errors.

Maybe you created a standard console project instead of a win32 project?

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

No one here will do your homework for you unless you want to pay some very big $$$.

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

From your profile ancient dragon, it seems that you have a pet dog. Can tell me more about your dog. I am interested in pets. When you start to work, you have to buy a house, get a wife. Everything requires money, in school everything requires good grades

I won't hijack this thread by talking about my dog (and cat too).

codeorder commented: :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since updateDifference() is a void function you can't set a variable = to it. The function is going to change the value of totalOfDifferences because it's passes by reference. Example below.

updateDifference(cashPrice, creditPrice, totalOfDifferences);
cout << " prices is now R " << totalOfDifferences << endl;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The way to solve it is not to put that function call on the same line as the cout statement. Put that function call statement on its own line before that cout line so that the cout and display the new values of those variables.

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

That's what I thought. Its a void function. How do you expect cout to print the return value of a function that doesn't return anything???

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

Would you put a link to the Top of the page on the bottom of the page like many web sites do? Its annoying to have to use the scroll bar to scroll back up to the top.

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

You failed to include <iostream> and <string> and the using std::cin; , using std:cout; and using std::string; statements.

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

I use IE8 exclusively. I have google chrome installed but don't like it. I've used FF, but dropped it when IE added tabs like FF has. As for speed -- I don't give a dam about a few milliseconds nor do I care about themes or add-ons or writing web applications for all those browers although I know that can be a big pain in the ass to do. All I need is basic browser to surf DaniWeb occasionally.

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

Student life hell???? HaHaHaHa. Wait until you have to actually work for a living. Your time in college is only the bare beginning.

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

>>avg = ass_average(int num_students, int j);

When you call a function you do not put the variable types as part of the parameters. That's only for function prototypes. All you have to do it put the variable names as the parameters, like this

avg = ass_average(num_students, j);

cdn88 commented: Thank you for such a quick replay, that fixed it! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

dev-c++ is no longer recommended because its ancient, lots of bugs, and no longer supported.

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

line 56 is wrong because the linked list is initialied to NULL every time that function is entered. What you have to do is pass variable start from main() as a parameter into make_list(), like this (Note the double asterisk, or double pointer).

struct queue_node *make_list(struct queue_node** start)
{
  char buffer[11];
  struct queue_node * current, * new;
  int j;
  for (j=0;j<2;j++)
  {
     new = add_node();
     if (*start==NULL)
     {
        *start = new;
     }
     else 
     {
         // locate end of linked list
         current = *start;
         while( current->next != NULL)
            current = current->next;
         current->next = new;
     }
     accept_input (new, buffer );
  }
  printf("%s<current>", current->word);
  printf("%s<start>", start->word);
  return start;
}
nadleeh commented: :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

m a bit confused...how can it b written in C coz again u will need a C compiler to compile it..
also if it is written in assembly..then how can the code run on different machines..i mean,assembly language would be different for different architectures,won't it..??

printf() is not a built-in function, but instead it is a library function, and all library functions are compiled with the C compiler. C compilers do not have any built-in "functions".

How library functions are written is up to whoever wrote the compiler, or is implementation dependent. Microsoft may write it in C language, but Borland might write it in assembly. Microsoft has actually done it both ways with various compilers.

Its true that assembly language functions restrict their use to only one architecture. Such fucntions have to be completly rewritten to port to others.

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

>>Well, then what is the point of being NULL? Why set it to zero?

In c++ NULL is just a macro (see this link if you don't know what a macro is) that is defined to be 0. Normally NULL is used to initialize pointers to a known address so that the pointer is never confused with some valid address. NULL means nothing at all when used with integers because 0 is a valid integer value. So it makes no sense to assign NULL to an integer. c and c++ languages do not have any way to tell us that an integer is uninitialized, or has no value at all.

iamcreasy commented: Awesome, exactly what I was looking for. +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The same way you access any of the Microsoft win32 api functions. This is c++ forum, not vb.

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

>>When I run the program and enter the value for cSalary the program just closes
You have to put something at the end of main() to prevent that from happening. One way to do that is to add a line cin.get() before main() returns. Programs execute the lines from top down, that is, it first executes line 1, then 2, then 3, etc. That means you can not put the calculations before the value of the variables are known to the program. For example, the value of cSalary is initialized to 0 on the first line, so the value of raise is cSalary * 0.05 which is raise = 0 * 0.05 = 0. Then on the very next line you have nSalary = cSalary. Since the value of cSalary is 0 (from the previous line) the value of nSalary will also be 0.

To fix that problem you have to put the calculations in the order in which you want them executed.

start of loop (do this 3 times)
   display current salary
   increment salary by 5% (e.g. salary = salary + (salary * 0.05);
end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are experiencing a very common problem for new coder. When you enter Y for answer then you also press the Enter key, which is '\n'. That key stays in the keyboard buffer because your program only extracted the first character that was typed. You have to flush all the remaining charactgers from the keyboard to that the the program will want for you to type the answer to the next question instead of just getting whatever characters are already in the keyboard buffer.

One way to do that in c++ is described in this article written by Narue.

Khoanyneosr commented: Thanks very much! I'm pretty new to coding, I've only coded C++ for about six months and really appreciate your help. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can not get the source code from binary exe files. The best you can do is disassemble the program to get assembly language source files.

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

GUI and RS232 serial port program are unrelated. Here is a list of the Windows Communications Functions. Start out by calling CreateFile() to open the serial port, then BuildCommDCB() to set up the port configuration (stop bits, data bits, parity, etc). Then ReadFile() to read from the port and WriteFile() to write to the port.

Here is a more thorough explanation with a few sample programs

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

As with many other things there are no right or wrong answers to the questions you have asked. One programmer may do it one way while another programmer will do it some other way. Its all a matter of personal preferences, or in some cases, company coding policy.

1. Generally, yes that's true. But there are always exceptions, and those should be very rare.

2. As long as you don't overdo them, such as writing a function that does nothing but write HelloWorld to the console window. I had an interview with one company whose coding policy was to put no more than one if statement in a function. That was going beyone what I believe to be the extreme right end of the line.

3. An alternative is to put all those parameters into a structure and pass a pointer to the structure.

4. I had one supervisor that couldn't even read C/C++ so I had to comment every line. The code looked horrible to me, but I had to give the boss what he wanted. At a minimum there should be a comment at the beginning of each function that explains the purpose of the function and possibly explain each of the arguments. Comments should appear elsewhee in the function to explain difficult-to-follow code.

5. Absolutely yes! The more practice you get the better and easier it will become. Great violinists do not become so great by playing computer games all the time.

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

>>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

>> 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

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

bingo!

tomtetlaw commented: i wouldn't have noticed my mistake without AncientDragon :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To fix the capitalization problem you should convert the entered string to all lower-case or all upper-case, or use a case-insensitive comparison function.

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

what operating system?