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

The case statements are irrelevent -- they do absolutely nothing, so you should just delete them.

if(TFGame.ToggleWarhead == true)
               {
			SMNameArray[0] = "Shield (50/30)";
			SMIndexArray[0] = 1;
            		SMNameArray[1] = "Protector (200/30)";
			SMIndexArray[1] = 2;
			SMNameArray[2] = "Portal (200/30)";
			SMIndexArray[2] = 3;
			SMNameArray[3] = "Armory (200/60)";
			SMIndexArray[3] = 4;
			SMNameArray[4] = "Generator (300/60)";
			SMIndexArray[4] = 5;
			SMNameArray[5] = "Outpost (600/90)";
			SMIndexArray[5] = 6;
			SMArraySize=6;
           }
	    else
          {
			SMNameArray[0] = "Shield (50/30)";
			SMIndexArray[0] = 1;
		        SMNameArray[1] = "Protector (200/30)";
			SMIndexArray[1] = 2;
			SMNameArray[2] = "Portal (200/30)";
			SMIndexArray[2] = 3;
			SMNameArray[3] = "Armory (200/60)";
			SMIndexArray[3] = 4;
			SMNameArray[4] = "Generator (300/60)";
			SMIndexArray[4] = 5;
			SMNameArray[5] = "Outpost (600/90)";
			SMIndexArray[5] = 6;
			SMNameArray[6] = "Warhead (3000/180)";
			SMIndexArray[6] = 7;
			SMArraySize=7;
             }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want any responoses you need to state the compiler and operating system you are working with.

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

We have an entire sticky thread devoted to books which you will probably want to read.

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

Is this a question? If it is, then I don't get it.

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

cin.ignore() does not affect any of the characters in the std::string, only characters in the input buffer. If you want to delete the period from std::string then you have to do it some other way. For example, one way to do it is like this:

std::string line;
line = "Hello World.";
size_t pos = line.find('.');
if(pos != string::npos)
   line = line.substr(0,pos);
cout << string << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is an extensive thread that discusses how to use it.

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

>>When writing your own operating system, wouldn't you have to incorporate your own way to read GUI?

Not necessarily, if you make it compatable with X11 then you can use most standard *nix GUIs. The GUI is only a method for humans to interact with the monitor and keyboard. It has nothing to do with the operating system itsef.

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

MS-Windows tutorial. You need a fundamental knowledge of the C language, c++ will work too, but not required.

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

Oh I see now -- the problem is that you misspelled "namespace".

>>If I`m doing mistakes sorry but I`m still practising English.
Your English is pretty good -- you are doing a good job at it :)

ddanbe commented: RESPECT! You have a fine eye! +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what compiler and version of compiler are you using? The first header file, stdafx.h, is for Microsoft compilers, and should be surrounded with quotes, not angle brackets #include "stdafx.h"

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

Since you didn't post any code I can only guess that you failed to include header files and identify the namespace.

#include <iostream>
using namespace std;
...
...
/blabla
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if(users[userName].name

UserName is std::string, not an int. My guess is that the function need to search the User array for the username, then use that index number in the quoted line.

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

I have not actually worked with file mapping, but I suspect the problem is that std::string attempts to allocate memory which causes the file mapping to crash. Try replacing std::string strData[ 200 ]; with character arrays char strData[200][255] and see if that fixes the problem.

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

I'm not completely certain what you are attempting to do, but here is one way to do it. It is not necessary to close the file and reopen it. Just reset the stream back to the beginning of the file, as shown below.

std::string line;
for( ;; ) // infinite loop
{
    while( getline(answer, line) ) // get a line of text
    {
          // do something with this line
    }
    // end of file reached, so now rewind back to the beginning
    // and start all over again
    answer.seekg(0, ios::beg);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Two problems:
1) need a return value to return the factorial. Your function does the recursion but doesn't calculate anything.

2) The function's return value should be int, not void.

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

Haven't you learned yet to read error messages and fix problems? The first error message ways noOfBooks is not been defined on line 119. Well, what do you think is the problem? If you look at the parameter list you will see its called noOfUsers, which isn't the same. The fix: change the damed thing.

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

Yea, go buy one and set it up in your back yard. I wounder if your neighbors will notice :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
struct sale
{
int *week;
int *units;
int *price;
char *name[30];
}weekly_Sale [13];

   for(i = 0; i < 13; i++)
   {
       scanf("%i %i %i %s", &weekly_Sale[i].week, &weekly_Sale[i].units, &weekly_Sale[i].price, weekly_Sale[i].name);
   }

>>.....would that snippet of code work?
No -- why did you change the structure to use pointers? Put the structure back the way you had it.

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

From what I read this morning Ford doesn't want or need any bailout money at this time. It is either going to fix its own problems by itself, or wait until next month when Obama will be in charge.

And Bush is going to nationalize the two remaining auto companies -- Crysler and GM -- by buying shares of stock for 17.5 Billion or so. That puts the government in charge of building cars -- a very very bad idea.

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

change #include <string.h> to remove the .h extension -- #include <string> That will not fix all your proglems will fix some of them.

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

ExitThread() belongs inside a thread, not in main().

ExitThread is the preferred method of exiting a thread in C code.

There are other methods available to keep main() alive until the threads terminate on their own.

#include <windows.h>
#include <process.h>
#include <iostream>

using namespace std;
unsigned __stdcall Display(void* p)
{
	Sleep(500);
	cout << "Display" << endl;
	cout << *((int*)p) << endl;
	return 0;
}
int main()
{
	unsigned taddr = NULL;
	unsigned createFlag = 0;
    HANDLE handles[5] = {0};
 	for(int i=0;i<5;i++)
	{
		if (handles[i] = (HANDLE)_beginthreadex(NULL,0,Display,&i,createFlag,&taddr))
		{
			cout << "success" << endl;
		}
		else
			cout << "failed" << endl;
	}
    WaitForMultipleObjects(5, handles, TRUE, INFINITE);

	cout << "main's execution is over" << endl;
}
Agni commented: Thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>ExitThread(0);
delete that line in main()

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

>>e.g. data1.c

The file extension is somewhat important -- *.c files are normally c programs, not data files. Your data file should be names "data.txt".

You need to store the data in an array of struct sale objects. What you are doing is just overwriting all the data on each loop iteration. So just declare an array and use it.

And a for loop would be more appropriate here than a while loop.

struct sale Weekly_Sale[13];
   for(i = 0; i < 13; i++)
   {
       scanf("%i %i %i %s", &weekly_Sale[i].week, &weekly_Sale[i].units, &weekly_Sale[i].price, weekly_Sale[i].name);
   }

Now it is a simple matter to store all that information in a file

FILE* fp = fopen("data.txt","wb");
if(fp !=  NULL)
{
     fwrite( Weekly_Sale, 13, sizeof(struct sales));
     fclose();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is not UNICODE -- its just a character from a special font. If you print that out (see below) you will see that it has a decimal value of -105.

int main()
{
    char c = '—';
    cout << c << " " << (int)c << "\n";
    return 0;
}

So in your program just check for a character whose ascii value is -105 and change it to --.

At least that's how it works on an American keyboard and Vista Home. Other keyboards might be different, I don't know.

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

Whose c++ compiler? Borland? Then you probably need a newer compiler because that one is pretty old and obsolete. You can download free several compilers, such as VC++ 2008 Express, Dev-C++ and Code::Blocks. Just google and you will find the links.

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

I would think it would be a lot easier to work the the digits as strings instead of integers. For any given number:
1) Is it a single digit -- yes, then its a Palindromic number

2) If two digit number, are both digits the same: -- yes, then its a Palindromic number

3) for larger numbers, check if the first and last digits are the same, if yes, then check the second and next-to-last digits. Keep checking inwards until either no more digits or just a single digit left. If the algorithm gets that far, then its a Palindromic number.

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

yes that will work too. Please re-read my previous post because I added more.

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

lines 13 and 14: the size of the vectors is 0 because you have not assigned any elements to the vectors. Therefore the loop starting on line 17 will never execute because both s and decksize are 0.

similar lines 31 and 32 cause program to crash because deck does not have a size.

How to fix: before line 31 assign a size: deck.resize(52); Even despite the above problems that shuffle function doesn't work because rand() often returns the same value, so the shuffled deck will contain duplicate values. What you need to do is keep track of the values returned by rand(). Each time it generates a value, check the previous values to see if the new value has already been generated. If it has, then generate another number until it finds a unique number.

You also need to delete line 20 because erasing the contents of the vector willl also cause the program to crash.

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

why should it return anything? just make the function void.

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

try it, time it, and find out if it will make any noticeable difference.

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

>>for( ; fscanf( fin, "%d", &x ) = 1 ; i++ )

Two things wrong with that:
1) where is variable i declared?
2) need to use operator == instead of = (common mistake)
3) what happens when the value of i exceeds the size of the array x ?

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

>> Is there any way to do this?

check the user input string to see if it contains a path -- e.g. the '\' or '/' character (path separators can be either character in MS-Windows os). Copy that part in another string so that you can use it whanever needed.

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

>>it will look like this "theArray[...][3]??

No. It is a one-dimensional array of structures. So it looks like this theArray[...]

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

>>ifstream in("C:\Users\Yaser\Documents\Visual Studio 2008\Projects\Vesta Coordinates\4vesta.txt");

I suppose you ignored all the errors and warnings your compiler gave you on that line ???? You have to double-backslash the directory separators ifstream in("C:\\Users\\Yaser\\Documents\\Visual Studio 2008\\Projects\\Vesta Coordinates\\4vesta.txt");

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

you have to know where the file is. Add the full path to see if the program will open it. ifstream in("c:\\myproject\\4vesta.txt");

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

My guess is the file is not open. Add this after the open

if( !in.is_open())
{
   cout << "Failed to open the file\n";
   return 1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Depends on the circumstances. Most of the time you will want loop counters to start at 0 because all arrays in C and C++ are 0 based, not 1 based. So the index number of the first element of any array is always 0. For consistency sake I always start loop counters out at 0 unless there is a good reason to initialize them with some other number.

A sorting algorithm is a good example of when to initialize the loop counter to something other than 0. Example

int foo(int array[], int nval)
{
    for(int i = 0; i < nval-1; i++)
    {
         for(int j = i+1; j < nval; j++)
         {
             // do something
         }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is c++ board, not C#. Which language are you using?

__declspec(dllexport)  class clsName
{
   // blabla
};

then in the c++ file

__declspec(dllimport)  class clsName
{
   // blabla
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CreateDocument() is a member of a class, so in the application program you have to declare an instance of that class in order to call it, unless of course it is a static method. My suggestion is to export/import the entire class instead of just one method.

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

line 14: >> for(int a = 0; a <= NULL; a--)

Do you know the definition of NULL? Answer: 0. That loop will execute as many times as it takes for a to wrap back around to a positive number, which could be a whole lot of iterations. for(int a = 0; a <= 0; a--) line 17: >>if(front >= front->next)
Why are you comparing the address of two pointers? What good does that do? Aren't you supposed to compare the data object occupied by the nodes?

My guess is what you want is this:

void dynintqueueEX::smallest()
{
    int lowval;
    //CHECK FOR EMPTY QUEUE
    if(front == NULL)
    {
        cout<< "\nQUEUE IS EMPTY! \n";
        return;
    }

    //step through qeueu - starting with front
    //to find the smallest number in the queue
    queuenode *temp = front;
    lowval = temp->value;
    while(temp)
    {
          if(lowval > temp->value)
              lowval = temp->value;
         temp = temp->next;
    }    
    cout << "Low value is " << lowval << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getline() doesn't work like that. What you want is this:

while( in >> lat >> lon >> R)
{
   // do something with that data

}

Now, if you want to keep all the data in memory at the same time, create a structure and then a vector of structures

#include <vector>
...
struct data
{
    int lat;
    int lon;
    int R;
};

vector<data>  theArray;
data d;
while( in >> d.lat >> d.lon >> d.R)
{
    theArray.push_back(d);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The while loop is incorrect

while( partin >> emp.id >> emp.skillLevel >> emp.yearsWorked)
{
    applicant.linkup(emp);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>#include "applicant.cpp"
Never, ever, under NO circumstances, do this!! DO NOT INCLUDE *.CPP like that. Instead, compile them separately and link the object modules. How to do that depends on the compiler you are using.

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

In c++ you could use the fstream functions

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

How to do it depends on the contents of file1. If file1 only contains one line of text then it should be pretty simple

ifstream file1("filename.txt");
ofstream file2("outfile.txt");
string input = "Hello World";
string line;
file1 >> line;
file2 << line << input;

It becomes a little more complex when the contents of file1 is more than one line. In that case you need to use a loop to read file1 and write to file2.

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

<snip> means I intentially omitted code, such as snip it with a pair of sizzers.

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

You are going to have to add more parameters to the bubble sort function. When the primary array members are exchanged, all the other array members must also be exchanged so that all the arrays are kept in sync with each other.

Example:

void bubbleSort(string Name[], int id[], float grade[], char letter[])
{
<snip>
 if (Name[index]> Name[index+1])                                {
{
       string temp=Name[index];
       Name[index]=Name[index+1];
       Name[index + 1] = temp; 

       int idtemp = id[index];
       id[index] = id[index+1];
       id[index+1] = idtemp;

        // now do the same think with the other arrays
}

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

No fix that I know. Try multiplying everything by 100 and use int math.

Freaky_Chris commented: thanks +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its a difference in compilers and the way they handle floating point arithmetic. VC++ 2008 Express produces 0. Dev-C++ produces the value you quoted. Dev-C++ is an old compiler now and may have a few bugs. Maybe someone with CodeBlocks can try it to see if the bug has been fixed.

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

you are attempting to pass an array of strings to getSize(), but it only expects an array of characters. getSize() is nothing more or less than your own version of the standard C library function strlen().