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

POST to the URL of the php script.

Unimportant 18 Junior Poster

That's fair, it would probably be more sane to make a purely relational table. If the OP has to ask about this though, it makes me wonder what I could suggest that would remain feasible.

Unimportant 18 Junior Poster

Make a column called parents and list every parent in some order of inheritance which is sane to you, as a comma delimited list of IDs.

Unimportant 18 Junior Poster

So, what files are you including?

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

I'm talking about line 84.

Unimportant 18 Junior Poster

While this won't answer your question, I thought I should bring it to your awareness...

echo "\t<option value=\" $data['ID'] \"> $data['Employer'] </option>\r\n";

Is totally valid, and you don't have to end php to produce HTML.
I say this because I feel that it would improve the readability of your code.

At any rate, why don't you check out the page in FireBug or something?

P.S. You </div> four times during <!-- SECOND --> while it is open only twice. I have no idea what it is nested in, but it could certainly matter.

Unimportant 18 Junior Poster

It will probably do what you expect if you get rid of calls to ToString(), because that value is an integer right?

Unimportant 18 Junior Poster

Why did you assume that DBNull is a valid value when accessing the information?
For example, perhaps it's valid to set the value to DBNull, but it's obviously not the correct format if you display it.

So, you could check if a column is NULL before taking action on it (IsDBNull()), or you could set the value to something valid in the first place.

Also, it might help if you add some try { } catch { }, as you are presently unable to identify the exact line of code which is causing you problems.
This tells me that your issue is not captured by the debugger in real time (Setting the value to DBNull does not cause the problem)

That means that your program crashes at a later time, in code you do not display here.

Unimportant 18 Junior Poster

Instead of deleting it, if you set a valid value, then what?

Unimportant 18 Junior Poster

Does the column hold numeral type or string type...? Which is it?

Unimportant 18 Junior Poster

if user_input == "done" then output the answer and quit,
ELSE, add user_input to the list of inputs.

Not--
add user_input to the list
THEN if user_input == "done"

Unimportant 18 Junior Poster

Oh excuse me, I was posting from the main page and in my haste I didn't even check the sub-forum, completely my fault.

replaceAll(" _-\\?", "*")

should be valid.

It's possible the character encoding is not what you expect it to be.
For example, if you are parsing an XML file or something.

Unimportant 18 Junior Poster

That depends on how replaceAll parses the string you provide.
Would you mind posting the code you use in replace all?
Besides, what language is this anyway? Many languages ship with regex_replace() type functionality by default.

Unimportant 18 Junior Poster

1.20 is not an "int"
Change "int" to "double"

Unimportant 18 Junior Poster

So do you have a specific question or are you asking for me to do your homework for you?

Unimportant 18 Junior Poster

What scope of reverse?
Each line? Each character?

Start by saving each line in an array of std::string, then iterate backward through that array.

If it has to be by character, you could add a reverse printing of each std::string by the same method.

If you want more help, at least try to solve this yourself.

Good luck!

Unimportant 18 Junior Poster
default:
    "Illegal option!"; // Did you forget std::cout? This obviously won't compile
Unimportant 18 Junior Poster

I'm not certain that I share your definition of 'stack' (any of them), so I'll ask you again, are you just trying to print your linked list in linear order?

Do you want to copy the data from the linked list into a stack type container? What is the stack implementation if that is the case? Is your stack FILO or FIFO? May I see your stack class or the name of a standard container you are using as a stack?

Unimportant 18 Junior Poster

How is this a stack?

Do you just want to print a linked list?

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 don't think that it is a compiler specific issue.
It may be an issue with the construction of ostream_iterator you pass the copy function.
I understand you are using this to write to the beginning of the std::cout file buffer, but I am unfamiliar with the copy semantics.

At minimum, ostream_iterator has an issue with the operators << and =, it is not resolving the type you are passing to the function. I don't think the std::string must be const type.

I think that you will need to overload std::ostream operator=, as the std::pair is not a primitive or normal output type, and it may find the shallow copying of the complex class to be insufficient. I do not believe that ostream handles std::pair's assignment by default, though of course I may be mistaken.

Unimportant 18 Junior Poster

& std::ostream_iterator<_Tp, _CharT, _Traits>::operator=(const _Tp&) [with _Tp = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, long unsigned int>

and that messy looking std::pair is actually how <string, long> is represented in the template hierarchy.

std::ostream_iterator = std::pair<std::string, unsigned long>; <--- is your issue imo

Unimportant 18 Junior Poster

It looks like the problem could be with ostream_iterator, though I'm not familiar with the copy algorithm, it seems like something I'd use a void function pointer for, or boost lambda if I was being lazy.

Would you mind posting the errors the call to copy generates (if any)? Yes I know, it'll be a terrible cloud of template-type errors that runs on infinitely down your compiler output, I hate those too... but they are a necessary evil :(

If there are no errors, please give an example of output.

Unimportant 18 Junior Poster

int *p1 = p0[0];

Unimportant 18 Junior Poster

MSVC, code::blocks, all the rest of the normal IDEs, etc.

Pretty much just google "C++ IDE", and take your pick at random if you have no preference.

I use MSVC 2008.

Unimportant 18 Junior Poster

For std::string, I'd do it this way:

// case insensitive string compare function
int compare_string(const std::string & s1, const std::string& s2) {
    std::string::const_iterator it1=s1.begin();
    std::string::const_iterator it2=s2.begin();

    size_t size1=s1.size(), size2=s2.size();// cache lengths
    //return -1 or 1 according to strings' lengths
    if (size1!=size2) 
        return (size1<size2) ? -1 : 1;
    //stop when either string's end has been reached
    while ( (it1!=s1.end()) && (it2!=s2.end()) ) { 
        if(::toupper(*it1) != ::toupper(*it2)) // letters differ?
            // return -1 to indicate smaller than, 1 otherwise
            return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1; 
        //proceed to the next character in each string
        ++it1;
        ++it2;
    }
    return 0; // sizes and values equivalent
}

You'll have to modify it a little bit to accommodate an array of char

Good luck!

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

I just explained this to you above.

word.at(i) = word.at(j); <-- you are changing the value of word

The reason I changed it to test for you, is because you aren't changing test.
When you output the contents of your test variable, it will be the same as when you set test equal to the value of word.

Basically, "word" is the only thing you are changing.

I also pointed out, that while you are changing it, you're also reading from the changed variable.

word.at(i) = word.at(j)
if i is 0, and j is 4
your word is attat

a = t

the word is now:
tttat

a = t

the word is now
tatat

You changed word.

You didn't reverse anything.

I specifically changed word.at(j) to test.at(j) because test is not being changed.


Edit: Here is a graphical example

std::string word("attat")
word[0] == a;
word[1] == t;
word[2] == t;
word[3] == a;
word[4] == t;

word[0] = word[4]; // <-- what did you expect? Why is it surprising that word changes when you personally change it
word[0] == t; // this now contains whatever character was in word[4]
word[1] == t;
word[2] == t;
word[3] == a;
word[4] == t;

word[0] = test[4];
word[0] == t; // this is the last letter of test, but
test[0] …
Unimportant 18 Junior Poster

word.at(i) = test.at(j);
compare to:
word.at( i ) = word.at( j ); // did you really want to write into what you're copying from?

As for your warning:
j = ( word.size() -1 );
j is an int, size() returns a size_t, which is an unsigned int
In this case, you can ignore the warning

the < is for the same reason, i < word.size() (int<unsigned int)
You won't be having any 2.1 billion character words, so you don't have to be concerned. The compiler doesn't know that, so it's warning you.

Unimportant 18 Junior Poster

No no, you already did it.

cmptr(cmptr &p)
{
  name = p.name;
  agp = p.agp;
  lcd = p.lcd;
}

The code above is from your code.

constructors are defined like this:

classname( args ) : class_initialization() { // post initialization code }
// in this case
cmptr( cmptr &p ) {
// means that if you construct this object with the address of this object as an argument, do whatever is where this comment is
}
// so when you create an instance of the object like this
cmptr a(); // default constructor
cmptr OTHER(a); // copy constructor, OTHER is now constructed based on the constructor that accepts an address (or pointer to) another object of the same type
// when you invoke the assignment operator '=' and you have not defined an
// overload for assignment, by default the copy constructor is invoked if the
// type is the same.
// Here we have an assignment:
cmptr pc_a();
cmptr pc_b = pc_a;
// which invokes the copy constructor

Good luck!

Edit: I changed my mind. Based on what you are doing, the assignment overload is necessary, as pc[1] would be initialized already by the default constructor when you create it with new, as you did not pass any construction arguments.

cmptr & operator=( const cmptr p ) {
  name = p.name;
  agp = p.agp;
  lcd = p.lcd;
  return *this;
}

That's an example of how to overload your assignment operator.

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

std::map<std::string,dvd> car_info;

std::map will sort this array automatically based on the < operator for std::string

std::map["volvo"] = dvd(constructor values); // or whatever temporary dvd you make

Unimportant 18 Junior Poster
cmptr pc[1]=pc[0]; // this is a redefinition
pc[1] = pc[0]; // this is what you actually wanted, assuming a was at least 2

cmptr *pc = new cmptr[100]; // this would be a = 100
pc[0].defaultinfo(); // both totally ok
pc[99].defaultinfo(); // both totally ok
// pc is a pointer to memory segment containing 100 copies of the cmptr object in sequential order
// the number you pass to the [] operator is an "offset", which adds the size of an object in bytes to the address of pointer &array[0]
// so, &pc + 100 bytes might be pc[1] if each object is 100 bytes in memory, but this is kind of semantics

// hence:
cmptr pc[1]; // is totally wrong, you already gave pc[1] a definition.

// Edit: don't forget to delete the memory pc points to when you are done using it:
delete[] pc;

Good luck!

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

To access a single member of a string, it's typically safer to call string::at(), as it checks that the value passed to at() is in range.

substr() seems really round-about for getting just one character.
std::string[] or std::string.at() are much better solutions for your problem

In terms of processing an integer value into a roman numeral string, it might be better to use an order of magnitude consideration (power of 10), and perhaps an (if greater than 5), since all numerals are segmented as:
1 11 111 (sub 1)5 5

Including the upper range above 5.
The only thing that changes with each magnitude is the character represented.

That may, however, have been out of the scope of what you are doing.

Best of luck!

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

Your problem is more related to the reason the limit system is a fundamental concept in calculus.

How many square sides do you need to create a perfect circle?
In this case, it's 1 per pixel.

How is that any less taxing than using a single trig function for each point in whatever granularity you specify?

If you don't care about accuracy, floating point computations are neither slow nor problematic with the right limitations. Not only that, but you could easily just do the math with an unsigned int type, flooring any decimal.

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

cout << line[count] // <--- you are returning uninitialized data, as the variable count can be greater than the size of your input.

Unimportant 18 Junior Poster

Is the file in the same directory as the .h you are editing?

Unimportant 18 Junior Poster
switch( var ) {
  case 1:
    // ;
    break;
  default:
    std::cout << "Default." << std::endl;
    break;
}

Any case except the integer 1 will output "Default.", as it is the default statement.

I cannot think of a different context for this question, if it's something else you'll need to be more specific.

Unimportant 18 Junior Poster

Is dt ever negative?
That could give you an undefined value depending on what complex math classes you are using.

In the real number system, a negative number has no square root (imaginary numbers required), as any number multiplied by itself will be positive.

As a quick test, why don't you try this:
sqrt(abs(dt))

and see if the NaN outputs are removed, if so, as this would lead to incorrect answers, you will likely have to create or use a class which can support complex number mathematics (such as imaginary numbers).

Best of luck!

Unimportant 18 Junior Poster

It may be worthwhile to note that scanf ignores blank input, newline, and tab. (in the context you are using it)

What I mean by this, is that blank input is still input, not EOF.

Unimportant 18 Junior Poster

My mistake, poster below me is correct.

Unimportant 18 Junior Poster

-1.#IND -> undefined (NaN)
-1.#INF -> infinity

I see you are doing quite a bit of math with potentially complex numbers, perhaps sqrt sometimes gives you a NaN which may be the source of your problem.

Such as -> ((beta*sqrt(divs[k][j])) * dW) + // where dW may be NaN, making the entire value NaN.

What I mean to say is that this is not corrupted data, but a mathematical problem.

Sorry I do not know what type of math you are really doing and cannot provide insight into which part may be giving you "NaN" values. The above is just a guess/example to help point you in the right direction.

Hope that helps!