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

In think there are two reasons for that
1) their age. 20 years ago people didn't start programming until they were at least yound adults and therefore had better research skills. Many people today start when they are young children, aged about 10 and the only thing they know is how to ask mommy how to go to the bathroom. Children of that age have been out of diapers only a couple years or so and are still trying to learn how to read/write their native language.

2) The internet. Why try to research for the solution to a problem when they can just post the question here (or on some other programming forum)? DaniWeb is to programming as a calculator is to math skills. If used too early in life they hinder rather than enhance the person's skills.

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

So that's wha you guys in Europe use :icon_eek: Next time I travel there I'll bring my own.

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

The first thing you need to do is understand the mathametics. Use pencil & paper and work that out so that you know how to make the calculations.

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

what does

if( strcmp(output, "file.txt") == 0)

do?

I don't intend to sound mean, but look up strcmp() in your textbook or google for it. If you can't undedrstand that then you are attempting to code stuff that is over your head. You need to start over and read your text book again from page 1, do all exercises, or read online tutorials more thoroughly.


>>Just use strings.
That doesn't help learning character arrays.

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

We know the requirements - you posted them in your original post.

Exactly what is it that you don't understand? If your compiler is producing errors, what are they? BTW the function prototype for fnTelephone_Num() is no longer consistent with the actual function. The parameters have to be identical.

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

I already gave you the starting code. Just add some stuff that's in your code snippet that I didn't include in mine.

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

>>if(output == "file.txt")
You can not compare two character arrays like that. You have to use strcmp() if( strcmp(output, "file.txt") == 0) >>if(b == "file.txt")
That is trying to compare a single character with a character array. And the line above it is asking you to enter a string of characters, not a single character. Declare b as a charcter array, then use strcmp() as previously mentioned.

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

Most companies require an Employer ID Number mainly for tax purposes. States and local governments also have uses for that number.

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

Not everyone in US owns guns -- I don't. It really depends on where you live whether you would need a gun or not. I live in a nice little rule town where there is no crime -- the town cop doesn't have a whole lot to do. But drive 30 miles away from here and there is St Louis Missouri, a city of over a million people and very high crime rate. Drive-by shootings and murders is just a daily normal occurence in that town due mostly to drug wars and gangs. This is not to say that St Louis is all a war zone -- some parts are pretty good.

In a perfect world you are right that we would not need guns except for hunting food. But we don't live in a perfect world.

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

As I said 17 hours ago Solved thread count is a useless statistic. I wish Dani would just get rid of it because it means absolutely nothing.

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

>>i get floating point error:abnormal termination in my console screen

Must be some other problem in your program because the code you posted should not give you that error. Post the entire program so that we can see what you did.

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

>>First, I recommend you use a boost::shared_ptr for all "next" pointers
He probably isn't allowed to use that.

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

Your function display() reuses the parameter variable which is supposed to be the maximum valid index value of the array. Your function destroys that and uses it for a loop counter.

void display(int a[], int max)
{
   int i;
   for(i = 0; i < max; i++)
   {

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

>>I use ver. 1.01 of TC, and I get an error on main() without a return int, but it will allow void main() with no return
TC is a very old and non-standard compiler, so anything is possible I suppose. That doesn't mean your program works correctly.

>>ya, int can be used because it reads/write files in binary mode
What happens of the file size is not evenly divisible by sizeof(int) ? Lets assume the file size is 3 bytes and sizeof(int) is two bytes.

Since int* buf is an uninitialized pointer, where do you suppose TC will store the data it reads from the file? Answer: TC will scribble it all over memory into some random memory location which your program may, or may not own.

>>Can you use an int pointer when you want to transfer char's however?
No. Not because of the difference between integers and charcters, but because use of int requires the file size be a multiple of sizeof(int). See above comment.

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

Look at enque() function, it already does it. If the queue is empty then it sets head to the new node.

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

LMAO :)

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

>>Oops, where'd AD's reply come from???? I reloaded before I posted to be sure...
That happens to us all -- no problem.

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

Once myBack (or head) is set, never change it unless you want to add new node to the head of the queue.

And re-read my previous post because I changed it.

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

>>i began having errors and now I am lost..
Sometimes its better to just scrap what you have done and begin again. But the next time you change the code compile frequently so that errors don't accumulate.

It looks like you are using myBack as the queue's head pointer. Wouldn't it make more sense to name that pointer for what it does? Most programmers will name it "head" meaning that it is the beginning of the queue. The only other optional pointer that may be useful is "tail", which points to the last node of the queue. tail isn't really necessary, just convienent because the program can easily find it by iterating all through the queue searching for the last node.

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

>>cin is a buffer, it needs to flush, just like cout
No it is not a buffer -- it is a c++ class. And cin can not be flushed. flush() only works on output streams, never input streams.

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

line 72: Andrew and Daniel are assumed to be variable names because they are not enclosed in double quotes.

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

You are probably right. But MFC was originally written before RTTI and has its own run time type information. This is discussed in more detail at the end of this link.

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

Did you test that program? What compiler did you use? The reason I asked is because variable buf is an unallocated pointer, so the program will most likely crash.

>> void main()
main() should be declared as either int main() or int main(int argc, char* argv[]) because it always returns int whether you want it to or not.

line 15: That's the wrong way to code the loop because feof() doesn't work that way. A better way to code it is to use the return value of fread() to know when end-of-file has been reached.

Reading and writing the file one byte at a time will take a very long time with large files. Use a larger buffer, say 256 bytes, and write out only the number of bytes read by fread()

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

The typecast is needed to convert m_pDlg from CDialog to serverDlg. And as ^^^ explained.

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

The number of solved threads is meaningless. That count includes all threads marked solved in which you participated, whether you solved the problem or not.

As you begin to post in more threads the ratio of solved threads will go down. Take mine for example. Only 10% of the threads that I have participated in were marked solved. My guess is that only 1% of those were solved because of anything I posted.

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

You have to enter a character 'A', 'B', or 'C'. To convert that into a numerical integer 0, 1, or 2 you just have to subtract 65 because the decimal value of the characr 'A' is 65. Look up google for "ascii chart" and you will see the decimal values of all 255 possible characters, some printable and others are not.

But, that is not a good way to code that program. What will happen if you enter a '0' instead of 'A'? Subtracting 65 from '0' will produce a negative value because the decimal value of '0' is only 48.

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

Getting "technical" is an absolute requirement in software development :)

jonsca commented: Props on your new avatar +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Inside the header file you have to tell the compiler that string is in std namespace. Putting using namespace std; in the *.cpp files is not sufficient because that line is located after the header file that contains the Phone class.

class Phone
{
public:
	void Set(std::string firstName, std::string lastName, int number);

	void Write() const;

	Phone(std::string initfName, std::string initlName, int initNum);

	Phone();

private:
	std::string fName;
	std::string lName;
	int Num;

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

Yes, you are correct about that behavior. There is really a little more to it, but that explanation will do for now.

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

The first one declares a parameter to the function. Actual storage for the array is declared in main().

The second one declares th array inside the function input() and the array is destroyed as soon as input() returns to whatever called it.

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

You posted the assignment, now tell us what question you have ???

>>int fnGenerateTelNumber(char cTelephone_Num)
That only declares a single character, not an array of characters. You have to
declare it like this: int fnGenerateTelNumber(char cTelephone_Num[]) or any of its other variants:
int fnGenerateTelNumber(char* cTelephone_Num)
int fnGenerateTelNumber(char cTelephone_Num[7])


When you declare the array in main() make sure you include space to hold the null-terminating character. If you want a 7-digit telephone number then the charcter array must be at least 8 bytes.

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

It was designed that way -- cin is a carry-over from C's getchar() and related functions, which behave the same way. There are no standard functions in either C or C++ that return to the program immediately when a key is pressed. If you want that behavior then you have to resort to non-standard functions such as those found in conio.h for MS-Windows/MS-DOS. *nix would use curses, and an MS-Windows port is available called pdcurses. On MS-Windows you could also use win32 api console functions.

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

LOL, am I the only one that uses www.msdn.com? That is like the end all be all of resources.

Only if you program for MS-Windows.

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

Here is an example.

int input(int a[]); // function prototype

int main()
{
   int a[100];

   int n = input(a);
}

int input(int a[])
{

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

You can thank the Chinese for the arms we have today because they invented gun powder in about 850 A.D. Without that we would still be throwing rocks at each other.

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

That is probably just as confusing as what I posted. Here is a link that better explains references and pointers.

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

scanf() expects the argument to be a pointer, and you passed just a float. Add the & to make num1 a pointer, like this: scanf("%f", &num1);

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

You've been watching sci-fi too much :)

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

The do exactly the same thing. The only difference is the way they are dereferenced, such as -> for pointers and . for references. Another difference is the way the sending function uses them, whether it uses & to create a pointer.

A vector can be passed by either pointer or reference.

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

There is an old saying -- "garbage in, garbage out". What you posted is not even C code. I don't know what it is, but he certainly isn't C or C++ languages.

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

1) functions have to be declared before they can be called. You need to add function prototypes before the main() function. For example: void readTemp(int kelvinNumber); now do the same thing with all the other functions.

2) There is no reason for main() to delare the two variables on lines 10 and 11 since main() does nothing with them. Just remove the parameter from the two functions and declare the variables inside the two functions that are called from main().

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

The problem is that the array is local to each function. The array in the input() function is destroyed as soon as input() exits. And the array in the display() function contains just random values because it is not the same array as that declared in the input() function.

What you need to do is declare the array in main() then pass it as argument to input() and display(). That way the array will not get destroyed between function calls.

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

On most 32-bit compilers, the size of an integer is 4 bytes. Since pa is an int pointer incrementing the pointer by 1 will advance the memory location 4 bytes.

A character pointer only occupies one byte of memory, so advancing a pointer by 1 wil increment the memory location by only one byte.

So in the original post pa+3 advances pa by 3*4 = 12 bytes. To do the same with pc you have to add 12 to pc to get pc to point to the same memory location that pa will point to.

The rule is: the compiler increments the pointer by the number of bytes to which it points. char *ptr, ptr = ptr + 1 the value of pointer is advances by 1 because sizeof(char) is always 1. int *ptr, ptr = ptr + 1 this pointer is advanced by sizeof(int) * 1 bytes, or on 32-bit compilers sizeof(int) = 4. If your compiler supports long long then such a pointer will be advanced (most likely) by 8 bytes because sizeof(long long) = 8.

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

I smell homework assignment. IDE is not really all that important -- enterprise application development can, and often is, done without IDEs.

IMO the most important features of a good IDE are:

  1. Allows the programmer to organize his/her project files
  2. Color codes the code's syntax for easier reading/understanding
  3. Highlights coding errors
  4. Easily compile the project files or the entire project with little knowledge of all that compiler's flags that may be necessary.
  5. The IDE normally contains a debugger that allows the programmer to step through the execution of the program one statement at a time, and view the changes of variables. There are a lot of other features of a debugger that I am not going to mention because that may require a whole book.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CDialog is the class name of a generic dialog class. serverDlg is a class that was derived from CDialog. So if m_pDlg was declared like this: CDialog* m_pDlg; then later assigned to a pointer of type serverDlg then the line you are confused about is typecasting m_pDlg from CDialog to serverDlg so that it can call the OnReceive() method. The typecasting would not have been necessary had m_pDlg been declared as type serverDlg instead of CDialog.

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

You can use any modern c or c++ compiler, such as Code::Blocks or VC++ 2010 Express (both are free). Do NOT use Turbo C or Tubro C++ because its too old and can not access any of the win32 api functions.

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

Oh, so he was talking about televisions, not PCs. Isn't an xbox sold in Europe the same as the xbox sold here in USA (I know the power supply would be different) ? So why would the games be any different (other than the languages)? I never played an xbox game, so I have no idea. I just assumed that if I bought an xbox game here in US I could take it to England and play it on one of their xbox machines.

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

Yes, of course it is possible. The entire win32 api (excluding .NET), including all graphics functions, were written in C language.

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

You don't. graphics on *nix is completly different than it is on MS-DOS/MS-Windows. Here is a source for linux graphics questions. You will have to be a member of their forum if you want to view that link.

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

>> is that right?
No. You have to use some if statements to check of the value of A > B, or B > C or C > A.