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

lines 55-59 -- that is the wrong way to code such a loop. See the way I showed it in my previous post. It will not work the way you have it if end-of-file is reached before matrix_size number of characters.

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

See this

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

>>message[0] = *type;
how is message declared ? is it a character array ? Yes, then the above only copies the first byte to message. Why just memcpy to message instead of using a temporary array.

memcpy(message, (char *)&number, sizeof(int));
memcpy(&message[sizeof(int)], (char *)anotherNimber, sizeof(int));
// etc
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Return values are normally passed back in registers -- its standard practice to put a 16-bit int (short in C) in AX, 32-bit in EAX or DX::AX and 64-bit on EDX::EAX. But you can do it anyway you want. pointers to arrays etc are done the same way.

If those registers contain anything the calling function needs to keep then push them onto the stack before calling the function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
char type[sizeof(int)];
memcpy(type, (char *)&numtype, sizeof(int));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int main()
{
    cout << (int)'£' << "\n";
    return 0;
}

The output of the above on my computer is -93. You'll have to change the local setting if you want to print that character from -93 because it doesn't print that with the standard american local setting.

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

>>I didn't figure out if it's possible to create 32 bit pointers in a DOS application
Yes, it is possible, depending on the memory model. use the FAR keyword to create 32-bit pointers in small memory model. 32-bit pointers are default in the large memory model. But that still can't address memory above the 1 meg limit.

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

certainly we can help, afterall that's what DaniWeb is all about :) Post the requirements and what you have done to solve it, along with compiler error messages and/or your questions.

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

Encryption only keeps the casual observers out -- professional hackers will break the encryption algorithm pretty easily. There has never ever been an encryption algorithm that has not been broken by someone, even the algorithms used by military can be broken given enough time and effort and is why they change the algorithms and keys frequently.

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

If you are passing smath to a function then you will also have to pass the number of elelemts, because there is no way for the function to get the number of elements from just a pointer. sizeof(any pointer here) in 32-bit compilers is always 4. sizeof(struct math) is 8. and 4/8 = 0.

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

>>I have added the code you have show below and I got errors:
Because you didn't put the code inside a function

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

Concerning 0 and '\0'. I still affirm that they are not the same. 0 is an integer and '\0' is a char.

no -- '\0' is the same as 0 -- put another way they are both 0x00. You can easily prove this yourself by using a debugger to view the contents of a character buffer after inserting both a 0 and a '\0'. Or write a hex dump of the buffer.

or simpler yet:

int main()
{
    char buf1[6] = {0,0,0,0,0,0};
    char buf2[6] = {'\0','\0','\0','\0','\0','\0'};
    int x = memcmp(buf1,buf2,6);
   printf("%d\n", x);

return 0;
}
jephthah commented: concise. and definitive. i have much to learn. +1
Aia commented: Sorry, C++ is not C -1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is it possible to allow someone to add new items to a poll after it has been initially created ? Often times I see that posters have other things they would like to add to the poll or something the OP forgot and would like to add.

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

try this:

string s1 = "abdxyzdxyz";
string s2 = "xyz";
size_t pos;
while( (pos = s1.find(s2)) != string::npos)
{
      string s3 = s1.substr(0,pos);
      if( (pos+s2.length() + 1) < s1.length())
        s3 += s1.substr(pos+s2.length()+1);
      s1 = s3;
}
Vishal_36 commented: after running your program its showing s1 still has "a" in it +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Upgrade to VC++ 2008 or use an earlier version of Access. VC++ 6.0 is no longer supported by Microsoft, and hasn't been for several years now.

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

how big is number ? Is array_size the number of valid elements in the array? If that is true then line 9 is wrong because there is no such element as number[array_size] -- should be number[array_size-1]

why is that reading the file one character at a time? The >> will skip all white space (spaces and tab characters). Why not something like this:

int index = 0;
while(index < array_size && fin >> number[index] )
  index++;

The above will read the entire file until either end-of-file or the max number of elements in the array is reached.

line 39: >> void create_matrix(int &number)
That's wrong. number is an array of integers and what you have there is a reference to a single integer. You want this: void create_matrix(int number[])

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

why is Student.Major and integer ? why not a string to that you can enter CS (computer science) or any other major ?

VC++ 2008 Express runs without errors too. But that doesn't mean there are no errors in the program. Actually there are several errors -- buffer overruns. For example line 73 and 138 are accessing non-existant array elements.

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

temp[i]=0; or temp[i]='\0';

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

>>if (fgets(filename,MAX_FILENAME_LEN,stdin) == 0) fgets() returns a pointer.
Yes, but 0 is the same as NULL -- NULL is defined as 0

>>0 is not the same than '\0'.
Yes it is.

>>quitstring[4]=0; quitstring[4] = '\0';
The two are equivalent

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

I found them annoying at first, but I've gotten use to them. The last post in the thread would be more useful, but too time consuming to implement.

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

>>All generalizations are wrong. Even this one.
I was only wrong once in my life -- that when when I thought I was wrong, but I was wrong.

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

people who say "pisses me off" in the subject title of threads :)

Seriously: code tags thing is probably the #1 complaint.

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

sort the lines just like you would sort any other set of strings, but instead of comparing the strings first find the first tab in the line and compare the strings up to that position

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

struct SAscendingDateSort
{
     bool operator()(string& s1, string& s2)
     {
         size_t pos = s1.find_first_of('\t');
         string ss1 = s1.substr(0,pos);
         pos = s2.find_first_of('\t');
         string ss2 = s2.substr(0,pos);
          return ss1 < ss2;
     }
};

int main()
{
    vector<string> lines;
    
    lines.push_back("Harvard Univ Americas \t 1 USA 1 100 100 100 100 100 72.4 100");
    lines.push_back("Univ Cambridge Europe \t 1 UK 1 99.8 93.4 53.3 56.6 70.9 66.9 73.6");
    lines.push_back("Stanford Univ Americas \t 2 USA 2 41.1 72.2 88.5 70.9 72.3 65 73.4");
    std::sort(lines.begin(),lines.end(),SAscendingDateSort()); 

    for(int i = 0; i < lines.size(); i++)
        cout << lines[i] << "\n";
}

Most likely the above will be a little more then what you really need. Just compare the entire string will sort them correctly too because no two lines will have the same university name. So this would probably be sufficient.

struct SAscendingDateSort
{
     bool operator()(string& s1, string& s2)
     {
          return s1 < s2;
     }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Does anyone know if there is someway to write something harmless to \\.\PhysicalDrive0 Nope. There is nothing harmless about writing anything to a drive. It is always a destrictive write (meaning it destroys whatever was written there before).

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

you have to allocate space to temp before doing that. You need length of chars1 + length of chars2 + 1 number of bytes temp = new char[strlen(chars1) + strlen(chars2) + 1];

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

any particular reason to use a hash? A simple linked list of structures would do the job. When done reading just sort the list by frequency and you're done.

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

>>...is that ok?
No.

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

>>which is the best way to sort the numbers at the end - use <algorithm> with sort, or do some loop to sort them?

Depends on whether you need to write your own sort algorithm or not. If you instructor doesn't care then I'd use std::sort because its much simpler.

You don't have to convert the string to numbers before sorting. The string wlll sort without such a conversion. But I guess that's part of the assignment just to see how you can do things.

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

zip the project up and attach it to a post. Don't include any object files or other files that are generated by the compiler. And it would be nice to know what operating system and compiler you tried to compile/link with.

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

Pizza may be one of America's favorite fast foods but was invented long long before the Americas were discovered.

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

You have to go all the way back to FDR to get to a president without some sort of military background. All of the presidents since then were military officers -- not one of them was enlisted. James Buchanan was the only enlisted president ever (private in war of 1812). DD Eisenhower had the longest and most distingished military career -- 5 star general who served from 1915-1954. It took an act of congress to allow him to retire so that he could become president, and then he was reinstated after his terms expired.

Link

[/edit]Oops! didn't notice that Bill Clinton didn't have any military background [/edit]

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

I don't like the crusts stuffed with cheeze, but I do like most everything else except fish. Too bad pizza is sooooo fatening. Why can't they make a fat-free pizza?

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

>> cannot find the answer there.
Click on the link "Restrictions on Default Arguments" in the left pannel.

You cannot use local variables in default argument expressions. For example, the compiler generates errors for both function g() and function h() below:

void f(int a)
{
      int b=4;
      void g(int c=a); // Local variable "a" cannot be used here
      void h(int d=b); // Local variable "b" cannot be used here
}

>>a correct code would be highly appreciated
The only correct way to do that is to make the local variable static.

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

>>Please understand, the world will not end.
Sorry to disappoint you but all scientists agree that our sun will become supernova one day. I think that will turn the Earth into a cinder ball.

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

The Chinese invented gunpowder around 1040CE, Marco Polo returned from China around 1295 CE, and gunpowder was first used in 1346 CE at the Battle of Crecy. They could have independently discovered gp but...

For all you older folks that's 1040AD, 1295 AD and 1346 AD. The term CE is not generally accepted anywhere in the world, only by college activists and athesists. Sorry, but we still use the Gregorian calendar.

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

Thanks for all the help people. Im just going to submit it with all the wrong stuff bcoz i don't know whats going on.

You give up too easily.

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

Did you read Colin's post ^^^ ? He gave you many hints. That error means that totalMass is not declared anywhere. Check the spelling very very carefully on line 7 of the code you previously posted.

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

>>We play here chess and domino (selfmade from kangaroo bones)
>>In free time we teach kangaroos how to program in VB and thats all excitment that we >>have here.

:) :)

Wal-Mart is the world's largest supermarket. I'm supprised you don't have them in Austrilia.

>>Tell me how ancient is dragon and where I can buy one
You can't -- its not up for sale.

>>Current cig lighters are to small and I keep loosing them, so dragon substitution should be resolution to continue with my bad habbit.
No -- solution is to stop smoking. I did it in 2001 after 40 years.

>>Sorry for my bad english, its not my native language I'm from australia.
Your English is fine. Nothing wrong with it. What is your native language? I though Austrilians spoke English.

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

Yes I made an error in my code. MSDN is the official source for help on all win32 api functions. Here's the link for GetWindowText(). You should always check MSDN before using win32 api and MFC functions/classes.

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

What are some of the errors -- you'll have to post them because I can't see your computer's monitor from my chair.

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

you can try something like this: But your tempValue buffer may not be large enough, depending on the length of the string. Should be at least string length * 7, maybe larger.

char temp[16];
tempValue[0] = 0;
// put below in a loop for each character
sprintf(temp,"0x%04X, ", Buffer[i]);
strcat(tempValue, temp);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

look at the first error message. What does it say? It tells you the line number that the error occurred on what what's wrong with it.

Still confused? Post the first few error messages here so that we can see them too.

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

You have at least two choices:

1) Use ClassWizard to give the edit control a variable name. Menu View --> Class Wizzard, elect the control id then Add Variable. For an edit control that will create a CString object which will be filled when UpdateData(TRUE) is called.

2) Get the CWnd* pointer to the control. GetWindowText() returns CString. In below IDC_EDIT1 is the id number of the edit control and yous might be different. Check resource.h for the correct control id or you can view it in ClassWizzard.

CString CTestmfcDlg::GetText()
{
	CWnd* pWnd = GetDlgItem(IDC_EDIT1);
	if(pWnd)
		return pWnd->GetWindowText();
	return "";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Of course it did ! That's what your assignment is all about. From what you posted all you are required to do is identify the errors and explain how to correct them. Actually correcting them and recompiling will help a lot because some errors may be hidden or not appear until previous errors have been fixed. And compilers often spit out a bunch of errors for the same line. Just concentrate on the first error for any given line because that is normally the problem.

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

>>inlining does not take place
And at the discrection of the compiler at all times. The compiler can decide to ignore inlining at all times if it wants to. inline is only a suggestion to the compiler, not a requirement that it has to honor.

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

Here is an explaination of default parameter values. That link talks about exactly what you are trying to do.

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

>> Dosnt the '<' operator for strings compare in alphabetical order
Not in alphabetical order but in order by their ascii values. Strings can contain a lot of other things than letters of the alphabet. The string "alpha" is less than "beta" because 'a' < 'b' (the first letter of each word. And "#alpha" is < "alpha" because '#' has a lower ascii value than 'a'

hammerhead commented: I didn't consider that possibility. +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you try to compile it? Or are you allowed to do that?

Read the line one at a time, pay close attention to spelling and variable initialization. I can spot three mistakes right away.

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

you could resort to C's stricmp(), or for some compilers, comparenocase() to make case-insensive comparisons if( stricmp(element.c_str(),Institute[m].c_str()) == 0) There is also c++ std::transform() that you could use to convert the strings to either all upper or lower case before comparison, but its a lot more ugly to read and code.

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

>>can you help me?
Nope -- don't know a thing about it.