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

line 31: Never ever for any reason call main() from any part of a program. In the example you posted use a loop.

line 23: what is cls? That line doesn't make any since at all.

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

Can't answer your question until I see your program. Why do you need to recompile just to choose another option? All you have to do is prompt for the option number and run a switch statement for the option. If you want to choose another option just put all that code in a loop so that it asks for another option.

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

Did't you click the "Buy Now" link?

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

Call fgets() to read entire lines of a file

char line[255] = {0};
myfile=fopen("garrudaRanch.txt ","r+");
if( myfile != NULL)
{
   while( fgets(line, sizeof(line), myfile )
   {
         // do something
   }
   fclose(myfile);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, that is odd using true to indicate the number of elements in an array. true is used for boolean operations, such as true or false, and you can't count on true being equal to 1, it could be -1 in some implementations.

Another point -- get rid of all those goto statements because they are considered very bad programming style.

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

Use the & operator to find out if a certain flag has been set, for example

if( dwStyle & WS_CHILD)
{
   // do something
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program is missing some header files that your compiler should have complained about. For example, va_start is undefined because you failed to include the header file that defines it. Learn to use google to find out where va_start is declared. You will save yourself an awful lot of time and grief if you start using google or another search engine more effectively.

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

Deposit $1Million USD in my PayPal account and I'll gladly do your homework for you. Otherwise, if you can't or won't do that, then post the code you have so far and we'll talking about the problems you are having.

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

Well, that can be done too. I'm not a web programmer but I do know there's a way to let users upload files to your server.

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

They wouldn't have to know hot to ftp stuff. Just create a web page with the names of the files and they could just click the link and download it to their own computer if they want to. I see that all the time on all kinds of web sites

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

you don't need vInt if all you are going to do is pass it to the Windows function. I don't know without testing if stringstream will work correctly like that, it may just return the char* instead of converting it to an integer.

Now that I think about it

stringstream ss;
int *iInt;
unsinged int x;
ss << argv[1];
ss >> x;
iInt = (int*)x;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In MS-Windows WaitForSingleObject() you can specify a time limit for the lock to happen.

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

why not just create your own web site where you can store anything you want on the file system. This would also eliminate the possibility that anyone on the internet can view the files -- your files could be much more secure from the public.

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

call strtol() to convert the string to an unsigned int, then assign that to a pointer of type unsigned char*.

unsigned char* ptr;
char* p;
unsigned int x = strtol(argv[1], &p, 16);
ptr = (unsigned char*)x;

or more simply

char* p;
unsigned char* ptr = (unsigned char*)strtol(argv[1],&p, 16);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The trick is to create a Fairy* pointer, then typecast the return from new to type Fairy, like below.

vector<Fairy*> farieList;
    std::ifstream in("Faries.txt");
    if( !in.is_open() )
    {
        cout << "Can't open the file\n";
        return 1;
    }
    string fairy_type, fairy_name;
    while( in >> fairy_type >> fairy_name )
    {
        Fairy* fairy = 0;
        if( fairy_type == "GoodFairy" )
            fairy = dynamic_cast<Fairy*> (new GoodFairy(fairy_name));
        else if( fairy_type == "EquiFairy" )
            fairy = dynamic_cast<Fairy*> (new EquiFairy(fairy_name));
        else if( fairy_type == "EvilFairy" )
            fairy = dynamic_cast<Fairy*> (new EvilFairy(fairy_name));
        if( fairy != 0)
            farieList.push_back(fairy);
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Lets say you want to decrypt and the original value of str[0] == 'v'. When the loop gets to 5 it will change str[0] to 'e' and continue the loop. Now its going to look for 'e' instead of 'v', and will find it when the loop gets to 21 and change it back to a 'v'. something similar may or may not happen with all the other letters. The break statement will stop the loop when the letter is first found.

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

why don't you just try it and see for yourself if it works or not.

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

Here is a link I found how to process command-line arguments in Windows Forms applications.

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

1. Change four functions in fairy.h to pure virtual functions and remove the corresponding functions from fairy.cpp. You will also have to declare the same functions in each of the other header files as just virtual.

// fairy.h
	virtual void askForWish() = 0;
	virtual void helpFairy() = 0;
	virtual void sayBye() = 0;

2. in main(), delete the fairy declarations and replace it with vector<Fairy*> fairyList; 3. Create a text file that contains the fairy type and fairy name on each line. Then in main(), have it read the text file, allocate the correct type of fairy, then call the vector's push_back method to add the fairy to the vector.

4. Finally, replace all the lines in main() that call talkToFairy() with a single line inside a loop which loops through all the items in the fairyList vector. According to your instructions you would just use [] to access the item in the vector, such as fairyList[i]->talkToFairy();

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

The only problem is that you have to put a break statement when the letter is found

void crypt(char str[], int strSize) {
	int i; int k;
	
	for (i = 0; i < strSize; i++) {
		for (k = 0; k < ALPHA_SIZE; k++) {
		
			if (str[i] == ALPHA[k]) {
				str[i] = CRYPT_ALPHA[k];
                break;
            }
		}
	}
}

void decrypt(char str[], int strSize) {
	int i; int k;
     
     for (i = 0; i < strSize; i++) {
         for (k = 0; k < CRYPT_ALPHA_SIZE; k++) {
             
             if (str[i] == CRYPT_ALPHA[k]) {
                 str[i] = ALPHA[k];   
                 break;

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

| is a bit operator. See this tutorial

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

strcpy() does not allocate any memory, it assumes you know what you are doing and have already allocated the required amount of memory. It also has two arguments, not just one as you posted.

Line 6 of the code you posted is also write. If you want to find out whether str points to "helloworld" then you have to call strcmp(str,"helloworld"); which will return 0 if the two strings are identical.

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

when you declare char str[] = "Hello"; the compiler allocates the exact amount of memory needed for the string. You can, if you want to, declare it like this: char str[80] = "Hello"; In that case the compiler will allocate 80 bytes of memory, initializing the first few bytes with the string. The second method is best if you know that str may eventually contain more characters, such as if you want to call strcat() to add additional characters or strcpy() to completely overwrite the existing string with something else.

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

It is customary to have program options to start with either - or /, such as -key or /key. Sometimes you may want an option to be something like "-key=Something", and you may also want to allow for spaces within the string, for example you may type on the commandline prog.exe - key = something That becomes a little more tricky because in that case the value of argc will be 5 instead of 2.

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

in main(), yes and sizeof will work as expected. In the other functions its just a pointer, even when declared as char str[] in the parameter list.

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

No, that's not possible either. What is sizeof(*str)? Answer: if str is char* then sizeof(*str) will be 1, which is sizeof(char). There is no way to get the allocated size a pointer. You can call strlen() to get the length of the string, but that may or may not the the same as the allocated size.

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

In main(), replace arraysize(str) with sizeof(str)

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

Change second example program like this: pointer(&p[0]); Also add NULL to this line: char *p[]={"name","fame","claim",NULL};

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

Now looks like this:

int main(int argc, char *argv[]) {

	char str[] = "someword";
	int strSize = arraysize(str);

you don't need that function arraysize(). This is where you can use sizeof operator because str is not a pointer.

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

This macro

#define ARRAY_SIZE(ptr) (sizeof(ptr)/sizeof(ptr[0]))

will return the number of elements in a 1D array.

No it won't. When ptr is char* then that macro will always return 4 because sizeof(ptr) == 4 and sizeof(ptr[0]) == 1 regardless of the number of bytes allocated to the character array.

That macro only works in the function in which the character array (or any other king of array) was originally declared.

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

>>Now the next part of my plan is a way to convert this char* representation of a pointer which will be passed in, to the actual numeric value of it.

Forget that idea, it won't, and can't work for reasons previously given. Pointers can not be passed between processes because each process has its own address space. Process A can not write into process B's address space, the operating system will prevent it by producing an Access Violation type of error.

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

See this thread for how to code managed enumerations. There should be no colon after the word public.

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

>>so i can skip the "int strSize = sizeof(str);" in every function.

Just as well because sizeof does not return the length of the buffer, only the size of a pointer (which on 32-bit compilers is 4). What you will probably have to do is pass the size of the array as another argument to the functions, such as void printstr(char str[], int size);

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

The parentheses are used to tell the compiler that the code inside is a typecast, which changes the datatype of variable msg from void* to class1*.

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

both Code::Blocks and vc++ 2010 Express are current and free. If you want the source code to be compatible with *nix then use Code::Blocks because that compiler is available on both operating systems.

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

The second program is wrong because line 8 is not passing a pointer to pointer, but pointer to pointer to pointer, which means that function pointer should have three stars, not two.

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

how big is he file? maybe you should zip it up then attach that.

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

In a program? None. makefiles are not used by programs, they tell the compiler how to compile the program.

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

The only difference would be to change the 4 (which is the size of a 32-bit integer) to the size of a float, whatever that is.

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

Create it exactly like you would a 1d array but twice as large. If its an integer array then it needs to be sizeof(int) * 20 * 20 bytes, or 4*20*20 = 1600 bytes.How you store the data is pretty much up to you. One way is to store all 20 integers of the first array first, followed by all 20 of the second array. So, the first integer of the first dimension would be stored at offset 0, while the first integer of the second dimension would be stored at offset 20*4 = 80 byte offset.

If you use a loop counter for data entry of all 400 integers, you can calculate the offset like this (assumes 32-bit integers):

int i = row number (0-19)
int c = column number (0-1)
int offset = (i * 20 * 4) + (c * 4)

Now just convert the above to assembly. let eax = i, ecx = c, and edx offset. I don't know mips asssembly, but just substitute those three registers in intel processors for whatever registers you have in mips.

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

Did you test your function? Looks ok to me, except you can delete line 11 where it sets the character to a space.

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

Yes, linked lists can be a bit tricky to program. Study some of these links

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

there is no problem with malloc() -- what you see is called undefined behavior, or array out-of-bounds error. The compiler won't complain about it because it assumes (usually wrongly) that you know what you are doing. What happens when you do that? The program just scribbles stuff all over memory, destroy whatever happens to be in memory at the time. Sometimes your program will crash, and sometimes not, depending what was in memory at the time.

The way to fix that problem -- Don't do that :)

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

The solution is identical to the RemoveSpaces() program I showed you in the other thread except check for vowels instead of saces.

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

I think I got rid of it, apparently was something I installed yesterday that caused it.

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

Example in this thread

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

What is this new advertising I see in threads -- some words look like links but when I hover the mouse over them an advertisement pops up.

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

google for "c++ odbc tutorial", there are lots of them.

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

Or better yes using an std::vector of std::strings could make life easy-peazy, no?

Not really. That's not much different than what he now has. a std::vector of structures or classes would work.