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

Use a version control program, some are free while others are not.

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

>>you really want to try to use modulus on a type double, then you could write your own function to mimic the modulus operator for ints.

or just call standard C function fmod()

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

double x = 46.62;
int cents = (int)x * 100;
int twenties = cents/(20*100);

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

fmod() is for doubles

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

Read this for return values

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

The posted program doesn't solve the original question, all it does is demonstrate one way to identify vowels. The OP would have to add quite a bit of code in order to complete the assignment.

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

Post the code how you got the first part to work. In the second part, create a 2d array of integers and read each integer one at a time using cin's >> operator (that's why I want to see your first code so that I can see how you are reading the file).

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

creating an object is done by Sports x; right?

Yes

and how to call getName()? x=Movie.getName(); this is not the correct way?

Yes, but that's not the code you posed. You can't expect people to help you if you don't post the correct code.

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

Just what do you expect getName() to return in that line? The statement Sport::getName() means that getName() is a static method of the class and name would also have to be a static member of the class.

Probably what you want is this->getName();

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

Line 17: Meh is not an array. You probably mean Me. The code below compiles ok.

class JK
{
  private:
     XY* Me;
     int ALen;
  public:

	  JK()
     {
        ALen = 1;
        Me = new XY[ALen];
     }
  friend ostream& operator << (ostream& Str, const JK &Meh)
  {
     for (int I = 0; I < Meh.ALen; I++)         //Put ALen here..
     {
        Str<<" "<<Meh.Me[I]<<" ";
     }
     return Str;
  }
};

Or you could add operator[] so that you can do it like this

{
  private:
     XY* Me;
     int ALen;
  public:

	  JK()
     {
        ALen = 1;
        Me = new XY[ALen];
     }
	  const XY& operator[](int i) { return Me[i];}
  friend ostream& operator << (ostream& Str, JK &Meh)
  {
     for (int I = 0; I < Meh.ALen; I++)  
     {
        Str<<" "<<Meh[I]<<" ";
     }
     return Str;
  }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Try this: And please call it a class instead of struct. Yes, they are both nearly the same, but class if preferred.

class JK
{
  private:
     XY* Me;
     int ALen;
  public:
     JK()
     {
        ALen = 1;
        ME = new XY[aLen];
     }

  friend ostream& operator << (ostream& Str, const JK &Meh)
  {
     for (int I = 0; I < ALen; I++)         //Put ALen here..
     {
        Str<<" "<<Meh[I]<<" ";
     }
     return Str;
  }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use a debugger and single step through the program until you find the problem.

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

sizeof(any pointer here) is always the size of a pointer, on 32-bit compilers it is 4 (bytes). The sizeof operator returns the number of bytes occupied by whatever object you give it, in this case you give it a pointer.

>>Shouldn't the size be 10? or the amount of elements?
No. See above. If you need to know the number of elements in the array you will have to keep track of it in another int variable. sizeof operator will not give you that information.

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

Are you allowed to use standard C functions? sprintf() can do all that for you, just a matter of giving it the correct forma spcification. E.g. "%x" converts to hex and "%f" to float

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

Put the function in another thread which would be started when the button is clicked. providing the function doesn't need access to any of the MFC windows or controls. That function (thread) would continuously post messages to the MFC main thread so that it can update windows/objects.

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

The button is running in the main thread. MFC doesn't create new threads for individual objects (buttons and windows) but has the same message pump that every MS-Windows has.

Which MFC class contains the function you want to run on button click? One way to handle that is in the Button's OnClick event handler post another private message which can be caught by the function you want to run. Or, just simply execute it from OnClick, assuming the function doesn't take long to execute.

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

Streams must be passed by reference like you did in main.cpp. So change inventory class like this: void ReadFromFile(ifstream&);

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

And what version of OS did you develop/compile it on? Does it run on other computers with the same version of MS-Windows? Your game may not be backwards compatible if you compiled it on Vista or Windows 7.

Another problem is that you are trying to run the debug version on another machine which may not have the debug version of MS-Windows DLLs. Recompile the program for Release mode and test again.

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

Just use Notepad or Notepad++, both are free and easy to use.

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

Depends on the debugger. What IDE/debugger are you using? If you are using debug.exe (which is no longer distributed with MS-Windows) the I think you are correct. When you use the 'l' command to list memory contents debug.exe just gives you a memory dump without regard to what's in it. You could, I think, view the entire computer's RAM like that, although I never tried to do that.

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

libraries with *.a extension were produced with GNU compiler, such as g++ on *nix and MinGW on MS-Windows. They are not usable with Microsoft compilers.

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

graphics.h is not part of c or c++ standards, so very few compilers support it. On MS-Windows the only compilers I know about that use it are Turbo C, which is ancient and obsolete. If you want graphics on modern operating systems then you need to learn modern compilers. Turbo C is nice to use for just your own programming enjoyment, but don't expect anyone else in the world to use it.

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

graphics.h is not part of c or c++ standards, so very few compilers support it. On MS-Windows the only compilers I know about that use it are Turbo C, which is ancient and obsolete. If you want graphics on modern operating systems then you need to learn modern compilers. Turbo C is nice to use for just your own programming enjoyment, but don't expect anyone else in the world to use it.

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

You need to learn how to recognize and correct errors.

double** changeArray(int rows, int columns)
{
	double **array = new double*[rows*sizeof(double*)]; 
	for(int i = 0; i < rows; i++)
	   array[i] = new double[columns]; // allocate columns for each row
	return array;	
}
int main(int argc, char *argv[]) {
	
	int rows = 10;
	int columns = 30;
	
	double** array = changeArray(rows, columns);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7 was slightly incorrect. It should have been this:
double **array = new double**[rows*sizeof(double*)];

Also in the code you posted, changeArray() is not called from main()

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

A 2d array might look something like this: Note that it has 2 asterisks, not just one.

double **array = new double[rows*sizeof(double*)]; // allocate the rows number of pointers
for(int i = 0; i < rows; i++)
   array[i] = new double[cols]; // allocate columns for each row
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

matrix is a 1d matrix, not a 2d matrix. You can keep it as a 1d matrix if you want to but that means you have to calculate the row and column index yourself.

This is one of the rare times I could start the i counter with 1 instead of 0 so that the calculation (i-1) does not become a negative number. And this needs two loops, not one.

for (int i=1; i<= rows; i++)
{
    for(int j = 0; j < colums; j++)
        cout << matrix[((i-1) * rows) + j];   
}
phorce commented: Great help :) - Thanks +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What version of MS-Windows?

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

line 26: you are not pushing enough things before calling printf(). The format string you are using calls for two integers. You need to push those two integers as well as the format string.

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

is it a free download ? i'm playing skyrim at the moment, i'm pretty addicted, my girlfriend is regretting buying it me now !;)

There's a free trial version, but somewhat limited what you can do. The full version is only about $15 USD

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

>>skip 16bit it is dead

Skip 16-bit programs yes, but you still have to know about 8 and 16 bit assembly instructions because they are still relevant in 32 and 64-bit programs, especially the string instructions.

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

I assume you mean 64-bit processors. The answer is yes because they are still in the x86 family of processors. Intel didn't completly replace the 32 and 16-bit processors, they added to them. 64 and 32 bit processors still use the 16 and 8 bit processor instruction set.

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

Anyone here play this game? I'm addicted to it and play for hours.

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

I'm exclusively Windows 7 and use either Code::Blocks or VC++ 2010 Express. Of course I don't do professional coding any more so I am free to use whatever I want instead of what some employer forces down my throat.

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

rohan: you have the right idea, but the code is incorrect. You have to allocate memory for my_strings

#include <iostream>
#include <cstring>

char ** tokenize_urls()
{
	char **my_strings;
	char *temp[3] = {"first","second","third"};

	my_strings = new char*[3]; // allocate memory for the array
	for(int i = 0; i < 3; i++)
	{
		my_strings[i] = new char[20]; // allocate memory for each string
		strcpy_s(my_strings[i],20, temp[i]); // duplicate the string
	}
 
	return my_strings;
}
 
 
void process_and_display_information()
{
	char  **my_new_char = tokenize_urls();
	for(int i = 0; i < 3; i++)
        {
		std::cout << my_new_char[i] << std::endl;
                delete[] my_new_char[i]; // delete the memory this string
        }
        delete[] my_new_char; // delete the array
}

int main()
{
	process_and_display_information();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Programming without Google? Hard to imagine!

Weren't you around before the internet? Back then we had to read books and compiler documentation :)

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

why do you need that array? they are all consecutive numbers, so you should be able to just calculate the value of freight id based on something else. I have no idea how you can derive freight id from the rest of the data objects in that program. Are you missing something from the assignment?

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

socket_connect
that function is use in php connection via socket

This is the C forum, not PHP.

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

They are in the libraries, just like the standard C functions. Whether or not you can view the code for those functions depends on the compiler you have. GNU code is free if you download the compiler's source code. The code for other compilers may or may not be free.

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

See this tutorial for C# arrays

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

>>and exactly wake up at that second right?
Wrong. That is only a hint to the operating system when to wake up the thread. It will be pretty close to 1 second but may be +/- a few milliseconds.

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

replace || with &&.

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

You can convert the string to time_t format so that later a comparison will be trivial comparison of two integers. First populate a struct tm, then call mktime() which will return time_t, something like this

// See previous post
char*	str = "2011-11-21";
tm tm1 = {0};

sscanf(str,"%4d-%2d-%2d",&tm1.tm_year,&tm1.tm_mon,&tm1.tm_mday);
tm1.tm_hour = 1; // for mktime()
time_t t = mktime(&tm1);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

make an array of HWND objects and call CreateWindow() 40 times. When one of the buttons is clicked windows will call your WinProc() function with the button's HWND.

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

I'm not a *nix programmer, so someone else will have to answer your question.

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

You are not allowed to change the datatype of an object -- in this case you can't reassign the data type from triangle* to rectangle*. Just use a different variable name for each one.

>>I deleted pointer, aka deallocated the memory.
delete operator only deletes the memory assigned to the pointer, not the pointer itself.

>>I thought that was the whole point of using 'pointers'.
You have a misconception of what pointers do. Its just like any other object, you can't have two or more objects with the same name.

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

>>exactly every second I need to call a particular function

Neither MS-Windows nor *nix is that accurate, actual time may be +/- a few milliseconds, depending on what else the operating systems and other processes are doing.

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

Thanks for assisting in proving my point, Ancient Dragon :D

The math you quoted was wrong. Both answers should have been 4 as someone else pointed out.

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

parsers start at the top of the program (line 1) and work themselves down. The bottom up approach would be a little like you trying to read a book backwards.