Unimportant 18 Junior Poster

I'll help you,
start by defining the entire state of the game.

We'll call this
int board[9] = { 0 };
A 3x3 space in two dimensions.
0 - Unknown state
1 - Player 1 claims
2 - Player 2 claims

Next, you want to allow input.
The simplest inputs are [position, player]
There are two players.

void set(int pos, int player) { board[pos] = player; }
Where player is [0-2] and pos [0-8]

Check for a cat's game!

bool catsGame(  )
{ // return false if any tile is unset
  for(int i=0;i<9;++i) if( ! board[i] ) return false;
  return true; // To be fair, you could detect a cat's game many moves ahead
} // I didn't take that higher complexity approach here.

Finally, you want to detect victory conditions.

int victory(  )
{
  // check rows [0, 3, 6] are left sides
  for( int i=0;i<7;i+=3; )
  {
    if( !board[i] ) continue; // Unset.
    if( board[i] == board[i+1] && board[i] == board[i+2] ) return board[i];
  }
  // next, check columns [0, 1, 2]
  for( int i=0;i<2;++i )
  {
    if( !board[i] ) continue;
    if( board[i] == board[i+3] && board[i] == board[i+6] ) return board[i];
  }
  // finally, evaluate diagonals [4] is center
  if( board[4] )
  {
    if( board[0] == board[4] && board[0] == board[8] ) return board[4];
    if( board[2] == board[4] && board[2] == board[6] ) return board[4];
  }
  // No winner detected.
  return 0;
}

You can …

Unimportant 18 Junior Poster

First you want to start a session.
session_start();

Unimportant 18 Junior Poster

isset() is a function, which checks to see if some object is set, or not.

|| is a logical OR operator,
In english, you could say, "OR"
if( condition OR condition ) then ...

In this case, !isset($_POST['potatoes'] should be !isset($_POST['potatoes'])
In my haste, I didn't add the closing parenthesis.

Edit: It would behoove you to understand the error messages, most of them are quite simple.

Unimportant 18 Junior Poster

Well, update doesn't return anything.
So of course you can't translate NOTHING into ROW.

Also, you don't need to wrap your query in parenthesis [ UPDATE table SET value=('value') ] Why not [ SET value='value' ] ???
Plus, it's better if you refer to post with quotes rather than symbol.
$_POST['value'] not $_POST[value]
You aren't necessarily wrong, but I'm fairly certain this behavior is deprecated for all but numeral type.

Unimportant 18 Junior Poster

Nah,
to begin with, you're trying to modify a const string,

const char * str = "Hello world";
str[0] = "J"; // This is totally absurd.

You actually want a block of memory just for pointers...

    char ** strings;
    int number_of_strings( 8 ), length_of_string( 260 );
    strings = (char**)malloc( number_of_strings * sizeof( char * ) ); 
    for(int i=0;i<8;++i) strings[i] = (char*)malloc( length_of_string );
    // Now you have strings[8][260]
    strcpy( strings[0], "Hello" );
    strcpy( strings[1], "World" );
    // Now strings[0] and strings[1] are valid

    // How you pass things doesn't matter, don't be absurd
    void acceptStrings( DWORD strings )
    {
      char ** passed( (char**)strings );
      printf( "%s %s", passed[0], passed[1] );
    } // This is vaild. A pointer is a regular number.
    acceptStrings( (DWORD)&strings );

    // Clean up the memory when you're finished.
    for(int i=0;i<8;++i) free( *(strings+i) );
    free( strings );
Unimportant 18 Junior Poster
class Hero:
  rope = false
  batteries = false
  radio = false
  room = "start"

  def move(self, dest):
    # define room change
  def get(self, item):
    # get item by symbol (flag true)
  # if batteries && radio then (OK to call for backup)
robotakid commented: Could you please explain that a bit more? I don't reakky get it. +0
Unimportant 18 Junior Poster
dec counter
cmp 0,counter
jz resetCounter
Unimportant 18 Junior Poster

You have 19 activities but you're trying to access the 20th one, which crashes your script.
Counting starts from 0.

Also, feel free to increment x outside of the if statement, since you increment it either way.

if (choice == "1")
  theirChoices.push(activityName[x]);
++x;
aVar++ commented: Fixed it now, thanks alot! +3
Unimportant 18 Junior Poster

WC_Cart::get_fees() is undefined.
You'll have to write the function.

Unimportant 18 Junior Poster

No, I meant for you to replace item(0) with item(selected) and set it to false, then set item(selected+1) to true. It's not the same.

Unimportant 18 Junior Poster

$.post('script.php'

in script.php
if(isset($_POST['names'])) print_r($_POST['names']);

Unimportant 18 Junior Poster

Beej's guides contain intros to network programming and interprocess communication which are both excellent.

Unimportant 18 Junior Poster

The two reasons with the greatest probability (IMO) are as follows:

1) The hardware specifications of your computer are too low. Reasons include but are not limited to: CPU clock speed, RAM amount and timing, motherboard front side bus speed, hard disk read and write rates, and graphics processing ability.

2) You have too much malware on your computer, which can result from an inability to assess the danger value of a particular action (ignorance) or general negligence regarding computer security (laziness).
2a) If you're using a fresh install of Windows 7, go ahead and invalidate this option.

Unimportant 18 Junior Poster

From the example given in PHP Manual mysqli::query

if (!$mysqli->query("SET @a:='this will not work'")) {
        printf("Error: %s\n", $mysqli->error);
    }

If you do this, it may give you some insight.

mmcdonald commented: Helpful, but already had it in :) +2
Unimportant 18 Junior Poster
string before = "Deleting 11 files.ABC: Total Time = 01:16:30, Remaining Time = 00:00:00";
string after = Regex.Replace( before, @"[,= ]", "" );
Unimportant 18 Junior Poster

in the file where you set $_SESSION['var']
make it do this
<?php echo $_SESSION['var']; ?>
then in the other file,

$.get( "session_page.php", function(data) { $("#my_field_id").html(data); } );

and it will probably do what you're trying to accomplish.
Though, I'm using jQuery.

PoisonedHeart commented: Thanks! +3
Unimportant 18 Junior Poster

...seriously?
At least make the smallest attempt to accomplish your goal.

Write at least 100 lines of code and return only after that, with a specific question about why you are stuck. How do you expect to learn if you're spoonfed your answers from start to finish?

Besides, programming is just calculus, even if you don't realize it yet. The critical thinking required to create functions cannot be attained through copying others. Feed your brain for a change.

Edit: Sorry for coming off as 'sharp', but posts like this make me narrow my eyes a little bit.

Ketsuekiame commented: Totally agree +1
Unimportant 18 Junior Poster

If it does what you want it to do then I'd say it's fine.

If you want to improve it, make it perform the calculations in 1 iteration, as you pass every value of n either way (remove redundancy). You could also make it easier to get a wider variety of data, based on whatever criteria you want.

The reason I recommended using a struct (or class) for the data, is so you could expand on what you are doing and handle each case automatically. Sorting can also become trivial.

For example, if you know the output of the entire expression based on a single variable, why not simply pass that variable to an object constructor in the first place?

class Example {
public:
  Example() { } // useless default constructor, modify if necessary
  Example( double n, double i ) {
    double h=1./n;
    x_i = h*i;
    // etc
    // you might use a parent class to track y
  }
  print() { std::cout << a << " , " << b << "\n"; } // example
  double get_a() { return a; }
private:
  double a, b, c; // example private variables
};

So if you have a vector of Example (std::vector<Example>), you can simply iterate from say, 1 to 100, and in the constructor of Example, process all 10 possible values of "n" to create all variations of the object at once. This has a neat side effect of giving you related data in the same area.

Unimportant 18 Junior Poster

I was curious so I trolled google a little bit, and chanced upon a solution to your problem:

namespace
{
std::string toString( const std::pair< size_t, size_t >& data)
{
    std::ostringstream str;
    str << data.first << ", " << data.second;
    return str.str();
}
} // namespace anonymous

std::transform( 
    some_map.begin(), 
    some_map.end(), 
    std::ostream_iterator< std::string >( std::cout, "\n" ),
    toString );
gerard4143 commented: Thanks for trolling around +4
Unimportant 18 Junior Poster

I really don't think what you want here is a switch, it would make sense in the ruby language, but C/C++ switch statements only accept constants:

switch( sum ) {
   case 100:
   case 99:
   // ... // yes you have to write them all
   case 96:
     letter='A';
     break;
   case 95:
   ...
   case 86:
     //
     break;
   default:
     letter='F';
     break;
}

The switch can cascade (note that I didn't break unless I reached a letter), but I think you'll actually get a slower speed than the simple boolean evaluation you are doing.

Good luck!

Edit: I changed my mind.
This switch statement will be faster than your code.
The reason is because a switch uses the constant as an offset to function pointer (linear access time), so no evaluation is done.
I think for any if-else chain of 3 length or greater, a switch will be faster if a switch is possible. (in C/C++ at least)
If that's questionable you'll have to look up the optimization in your native compiler, I have no intention of doing so. Feel free to correct me if you do this and I was wrong though!

kra9853 commented: Great help +1
Unimportant 18 Junior Poster

No, I told you from the start, this line of code is just wrong:
comptr pc[1] = pc[0]; // You can't do this.

Your compiler is telling you that's impossible.

pc[1] is already comptr
you are making it comptr "again"
comptr pc[1] <--- is bad because:
comptr *pc = new comptr[50]; // range 0 - 49, --> this is 50 comptr objects

This code also works:

comptr *pc; // note no new yet
pc = new comptr[50]; // there are 50 comptr objects now
// *pc is not a computer, it is a -pointer-
// it points to the beginning of the array (&comptr[0])
// pc[1] means, &comptr[0] + size in bytes of comptr (&comptr[1])

// so when you do this
pc[0].defaultinfo();
pc[1] = pc[0];
pc[2] = pc[1];
pc[3] = pc[0];

// all objects from pc[0] to pc[3] are equal to the value of pc[0]
// they are separate objects
pc[1].defaultinfo(); // now you can change pc[1]
// pc[0], pc[2], and pc[3] are still the same, they are their own object

comptr pc[4]; // ERROR. YOU ALREADY DEFINED PC[4], it is a comptr object -already-

You said:
"i think there is no way to get array1 objects specific items and put into array 2 objects."
and that's wrong, I am showing you how to do that.

Unimportant 18 Junior Poster

You did not read my post.
You had a compiler error because you redefined the array:

cmptr pc[1]=pc[0]; // this is a redefinition

You defined the copy constructor yourself, so if you want it to do something different, then change it.

cmptr(cmptr &p)
	{
		name = p.name;
		agp = p.agp;
		lcd = p.lcd;
		
	}
// you didn't add most of the variables below
class cmptr
{
private:
	string rm;
	string hd;
	string nme;
	string agp;
	string mothrbrd;
	int lcd;
	int pcr;

...?

Unimportant 18 Junior Poster

Edit: You should remember that error message specifically, because it is a misleading one for less experienced programmers.

struct attrib{
char x;
int y;
char cont;
}; // <-- you didn't have a trailing semicolon
 
attrib brd[8][8]; //ERROR WAS HERE <-- no it wasn't
Unimportant 18 Junior Poster

Modify your for loop according to the values of n you want to iterate.

for numbers ranging from 10 to 10000:

for( i=10; i<10001; ++i ) {
}

would work just fine, so what's missing?

for( i=start; i<end+1; ++i ) {
}

just accept start and end as values from the user.

You can easily store each result from the for loop in an array, try using vector if you don't want to define a max size.

struct result_info {
  double i, x_i, y_curr;
  result_info(); // whatever constructor
  result_info( double a, double b, double c ) : i(a), x_i(b), y_curr(c) { }
}
std::vector<result_info> res;
res.push_back( result_info( i, x_i, y_curr ) );
output << res.back().i << " , " << res.back().x_i << " , " << res.back().y_curr << "\n";

Hope that helps, good luck!

raheel_88 commented: quick, concise response! many thanks +0
Unimportant 18 Junior Poster
template <class T>
T& foo(T &t) {
 // ;
}
template <class T>
T& foo(T &t, T &t2) {
 // ;
}

You may or may not be familiar with function pointers, but I'm going to use one as an example:

int foo(int x) { return x; }
int foo_caller(int (*foo)(int), int r) { return (*foo)(r); } // you can do fun stuff with void pointers here
int main() {
    void (*fptr)(int);
    fptr = foo;
    fptr(1);
    (*fptr)(2);
    foo_caller(fptr,x);
    return 0;
}

Now picture your compilers problem:
You want to pass a totally different kind of function.

I probably am about to go off on too much of a tangent, so I'm going cut it short.

Hope this was informative!

Unimportant 18 Junior Poster

Operators are just functions, the reason you cannot pass () and [] as the same argument is that they are not necessarily the same function, they have different memory addresses and associated methodology.

Rather, why not just overload your function?

void foo( int a ) { ; }
void foo( short a ) { ; }
Unimportant 18 Junior Poster

Poster above you was correct, please look at how this is different from what you did.

class myplayclass
    {
    public:
    int x;
    int y;
    vector<int> myVofInt2;
    myplayclass() : myVofInt2(10) {} // you can call its constructor like this
    ~myplayclass(){}
    myplayclass(int intX):x(intX), myVofInt2(10) {y=0;}
    };
     
    int _tmain(int argc, _TCHAR* argv[])
    {
    vector<int> myVofInt(10);
     
    return 0;
    }
Jsplinter commented: Thank you very much, I didn't realize there was a difference +1
Unimportant 18 Junior Poster

To read from a file, you might try using std::ifstream
If each item is on it's own line, one method you may try, would be storing each line as a std::string, and place them in an array of std::string. Then use your rand() variables to select an array offset (such as array[rand() % 35 + 1]), at which point you could remove that entry from the array, and reduce the range of your random by 1, you may want to first swap the element you remove with the last element in your array.

Good luck!