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

Why did you use list tags when you posted that code? That just makes it impossible for anyone to copy/paste into their compiler's editor. Please repost without using those tags.

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

Ohhh! I see what you mean. Thanks

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

Call win32 api function CreateThread(). Here are a few threads about that topic.

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

>>Look at their bbcode.
How ?

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

You mean you have two *.cpp files that you want to compile together into one executable program? Yes, put one in the program's main thread, create another thread during initial startup in main() then put the other code in the second thread. Exactly how to do that depends on the operating system.

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

This doesn't work very well any more. Something broke just today I think. See this thread and click the Toggle Plain Text link.The whole thing shrivels up to just one or two lines with vertical scrollbar.

In the last post in that thread all the text is placed on one line, making it impossible to copy/paste into my compiler's text editor. It looks as if all the line feeds get stripped out.

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

>>The program is working fine
your program may be complete but it is NOT working fine as you stated. Why? Because line 41 is wrong -- feof() doesn't work like that. And the loop from lines 46-60 is also written inefficiently.

vector<string> words; // an array of words
while( fin.getline(line, 100) )
{
       p = strtok(line, DELIMS );
       while( !p )
       {
              words.push_back(p);
              p = strtok(NULL, DELIMS);
       }
}

}

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

Sorry I can't help you any more because I don't have your compiler. You might post the question on Microsoft's technical forums.

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

use the fstream's >> operator, exactly as you already posted in your program using cin to get the name.

ifstream in("filename");
string word;
while( in >> word)
{

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

add this just before getline: cin.ignore();

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

Hi Ancient Dragon,
Do you know how to get the sequence diagrams from C++ Source code using Rational Software?


Thanks & Regards,
Manikanta.

Maybe I should have made myself more clear. No.

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

did you read any of these google links to see if they can help you?

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

You could just ask Rational :-O

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

Look in your program and see where WL_HMAC_SHA1 is used. right click on it and select GoTo Declaration. Hopefully the IDE will bring up the header file in which it is declared.

Make sure you have PocketPC SDK installed and the hardware vendor's SDK.

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

what do you need help doing ?

>># include <string.h>
That is the wrong header file which contains C functions for manipulating character arrays. What you want is #include <string>; , without the .h file extension

Do you know how to write a constructor ? You will find them explained in your text book. Have a go at it them repost what you did if you still have question about it.

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

line 28 and 36: array index values begin with 0, not 1. Those two loops will cause the program to write beyond the bounds of the array. Code them like this: for (count = 0; count < testscore; count++) You can do everything on just one loop -- no need to all those loops. After line 32 calculate the total and determine the highest and lowest values.

if( lowest > score[count])
   lowest = score[count];
if( highest < score[count])
   highest = score[count];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first error is because line 9 does not end with a semicolon.


line 111: you have to declare the data types of each parameter (int, float, double or something else???)

Fix those then recompile to see remaining errors.

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

Well, your compiler must have spit out a bunch of error messages. What are they? Post a few of them and the line numbers associated with the errors (your compiler tells you that too).

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

I don't think there is a "best solution". Binary search won't work because you have to compare both array dimensions to determine which is the closest. You can't do that with a binary search. The only way to do it is with a linear search and compare every pair of values. Doing anything else will just consume even more time than a linear search.

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

post a few errors (and the line numbers they appear on)

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

line 4: delete it because its redundent. Its not necessary to predeclared the class if your going to fully define it in the very next line.

line 13: As written that function does nothing. YOu need to add a bit of code that sets array Grade = array G.

line 18: that operator is not written correctly. Student x must be passed by reference, not by value, and y must have a data type. Its also missing ) at the end of the if statement

line 19: Teacher has not been declared yet, so the compiler will error on that line, which is probably the error you mentioned in your description post. Move the declaration of Teacher beginning on line 21 up above the declaration of Student and it will probably compile ok.

Lines 30-33: I don't think you can do it here even though it is declared a friend class. The compiler doesn't have any clue there array Grade is located. Best way to resolve this is to put the code in Student::setGrade method and pass array G to that method.

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

>>Why create an array?
You're right -- an array isn't necessary. Just keep track of the row that contains the value nearest 0 (whether positibe or negative)

if( abs(delta) <  closest_match)
{
    closest_match = abs(delta)
    closest_row = counter; // row number of array that contains the value
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not sure right now if this will work, but create a third array with 1000 rows that will contain the difference between the value in the array and the search value. Example:

array[0][0] = 2.00   array[0][1] = -200.00  
delta = (4.056 - 2.00) + abs(-200.375) -  abs(-200.0)) = 2.431

array[1][0] = 3.50   array[1][1] = -300.50  
delta = (4.056 - 3.50) + abs(-200.375) - abs(-300.5) = -99.569

In the above, array[0] wins because its delta is closer to 0 then array[1]'s delta.

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

line 40: You are attempting to use an uninitialized pointer as the input buffer to getline(). That will most certainly cause your program to scribble all over hell and back and is most likely one of the causes of the behavior you are reporting. On line 38 replace char *a; with this: char a[100]; Then you will have to rework the loop starting at line 43 to index into the array a instead of incrementing the pointer.

function ltrim(). you created a memory leak by moving the pointer string. Can't do that because you will never successfully delete it after doing that. What you need to do is locate the first non-white-space (using isspace() ) and then shift all the characters left to overwrite all those spaces and tabs.

I suspect there may be other similar problems in your code, but I don't have time to look for them.

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

line 11: that is a pretty screwy way to generate a random number. The normal method is to first seed the random number generator so that you get a different set of random numbers each time the program is run.

int main()
{
    srand( time(0) );
    int x = rand() % 100:

}

I think you have everything much too complicated. All you have to do is compare the guess with the random number.

if( guess < num)
   cout << "Your guess is too low\n";
else if( guess > num)
   cout << "Your guess is too high\n";
else
   cout << "Congratulations!  you guessed correctly.\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That form of cin.getline() only works with character arrays, not std::string objects. To use string do this instead. getline(cin, address)

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

Welcome to DaniWeb.

>>I'm not a guru so I might be in the wrong place
There are a lot of people who are not guru's. Please feel free to browse through all the boards and participage where you feel you want to, which I hope is often.

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

You have to declare three variables in main() and call calculateAverage().

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

you are using the wrong compiler. Get ancient TurboC or Turbo C++ and it will probably compile.

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

Post your code so that we can make suggestions.

>>I REALLY SUCK A C++!
Shhhhhh -- don't tell anyone but I think I do too :)

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

>>im a biginner level in Visual C++ version 6.0
That's unfortunate because that old compiler doesn't support c++ very well. You will be much better off if you download VC++ 2008 Express, which is free for the downloading.

Otherwise, I don't know the answer to your question.

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

InitApplication() references a function names WinProc. You have to add that function to your program before it will link successfully. That function will probably be explained a little further on in your book, or you can study this tutorial.

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

function profiling is calculating the amout of time it takes for a function or other algorithm to execute. Because they execute so quickly it is usually necessary to crete a test program that will run the test data through the algorithm thousands of times in order to achieve a measurable time.

This subject has been discussed here at DaniWeb and other programming web sites many many times. Here is just one thread you should read. You can find others here, some are relevent to your question and some not.

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

The functions in graphics.h are only supported by old ancient Turbo C and Turbo C++ compilers. Those functions can not be used by any modern 32-bit compiler. You can either get a copy of that old MS-DOS compiler or use win32 api GDI functions or get one of several graphics libraries such as OpenGL and QT.

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

Vijayan is saying this because it is not guaranteed that the character set will have the alphabetical characters 'A' through 'Z'or 'a' through 'z' represented by a contiguous block of integers

Although correct, I have never seen such an operating system, but there could be one or more very obscure os's that have that quality.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int main()
{
    int n = rand() % 26;
    char c = (char)(n+65);
    cout << c << "\n";
    return 0;
}
orbidden commented: Thanks, You were very clear and percise, it was very easy to understand. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have all the source code then just export it and recompile. Put the class in a *.h file and include it in the application *.cpp file like you would any other header file, then at link time link with the *.lib file that's created when you compiled the class.

Or a simpler way is to just add the class as another file in your project. No need for a dll or *.lib that way. But be careful to give full credit to the original autor by putting his/her name in comments at the top of that class file. If you don't you could be accuses of plagurism.

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

If you look at the code snipped I posted earlier you will see that the filename is surrounded by double quotes to that you can easily tell if there are leading and/or trailing spaces.

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

Look at the line number in the error message then look in your code at that line. That error means that you declared calculateAverage to be a void function, which does not have a return value. Delete line 15 of the code you posted because it is causing that error.

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

>> cin >> address;
The >> operator does not accept spaces. So if your address contains spaces it will pick up only the text before the first space. Use getline() to get everything including spaces.

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

Look at an ascii chart -- the letters 'A' - 'Z' have decimal values of 65 - 90. So just generate a random number between 0 and 26 then add 65.

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

Next step: display the name of the file that it is attempting to open, then compare it with what you think it should be. There is obviously something wrong with it. Even one mis-placed space will make a difference.

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

Is there a reason there is so much extra bloat in that program ? For example there no need for variable pb at all or for the parameter in function calc

Here is a somewhat simpler version: It could be simplified a lot more but I don't know what you assignment wants you to do.

include <stdio.h>
#include <stdlib.h>

int ave,sum_total=0,total;
int b,cnt=0;
int input[3];

void calc()
  {
  cnt = cnt + 1;
  sum_total = sum_total + input[b];
  }

int main(void)
{
  for (b=0;b<3;b++)
 {
    printf("Enter a value: ");
    scanf("%d", &input[b]);
    calc();
 }
  ave = (sum_total/cnt);
  printf("Cold Ave is %d\n", ave);
  return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You posted those in your original post -- I missed that :)

to use is_open()

ifstream FindFile( FileName3.c_str() );
if( FindFile.is_open() == 0)
{
   cout << "Error opening file: \"" << FileName3 << "\"\n";
}

Sorry that I can't be much more help because you didn't post enough of the code to allow me to compile and test.

If you run that code on any other version of Windows other than XP it will not work because "c:\Documents and Setting" doesn't exist on Vista.

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

It doesn't compile because it is missing the header file <fstream>

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

Please post the contents of NewDataGroup.txt -- or at least the first 5 or 6 lines if the file is really huge.

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

What are you trying to count? Number of examcodes for each student?

line 10: you want to use the == operator there, not the assignment = operator.

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

You don't have to specifically clear the vector because it will be destroyed and recreated on each loop iteration. Just wasting cpu cycles to clear it yourself.

>>foor-loop
Its spelled for-loop. There is no such word as foor, other than as a proper name. :)


>>What is the difference, Why does it work when I manually specify the pathway to the files
My guess is that the files are not where you expect them to be. After opening a file call the is_open() function to see if the open succeeded. I'll bet it failed. Carefully compare the files and their paths in NewDataGroup.txt with those you hard-coded in the program.

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

I realize you didn't post all your program, but what do you do with the vector ReadInData that is declared inside that for loop ? The entire vector is destroyed on each loop iteration and you do nothing with it but toss it into the bit bucket.

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

Nice commercial :) Hope they got permission to use that theme and film clips.