Unimportant 18 Junior Poster

Create a list...
Or a table...

These are <ul><li> and <table><tr><td>

Unimportant 18 Junior Poster

Use AJAX.

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

internal keyword

It means the member can only be accessed within a certain scope.
The scope is the scope of the assembly.

So for example, if you have a DLL which does some stuff internally, the external code which uses the DLL can't access the internal stuff.

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

You can phrase this as a 1D array,

    array[n] == array[ width * y + x ]
Unimportant 18 Junior Poster

Why are you freeing TX?

Unimportant 18 Junior Poster
Rectangle * rectangles(NULL);

// You can resize this in place.
rectangles = realloc( rectangles, number_of_rects * sizeof( Rectangle ) );

free( rectangles ); // Once you're finished.
rectangles = NULL; // Just for the sake of sanity in more complex cases.

Plus, you probably want a container class to handle indexing...
Without getting into too much detail here,

You'll want Rectangle->area(), ->width(), ->length()
and in the container class you'll want some function

Rectangle * operator[] ( int area ) { return &rectangles[area]; } // which can be NULL or OOB

If you didn't really index it this way, you'll need to iterate.
That means a loop of sorts.

P.S. Feel free to use new/delete if you never resize the array, they are faster operations for single allocations.
P.P.S Indexing by area seems unwise for a number of reasons, including but not limited to wasted memory.

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

What do you mean by other input?
You can modify the DOMXPath after it is constructed, though it takes a little doing.

I'm sorry, your request seems ambiguous at this moment. You'll have to literate yourself more specifically if you would like to find a specific answer.

Unimportant 18 Junior Poster

In simplest terms, you have a table of numbers in pre-determined but guassian or semi random order. If you pick a random starting point (seed), then you'll get what appears to be a random result.

Unimportant 18 Junior Poster
$files = array(  ); // or a class object
$dir = opendir( $name );
while( false !== ($file = readdir($dir)) )
{
  if( $file != '.' && $file != '..' )
  {
    $pop = explode('.',$file);
    $ext = "";
    if(count($pop)>1) $ext = array_pop($pop);
    $files[implode('.',$pop)][] = $ext; // You may want to save other attributes as well, shrug
  }
}
closedir($dir);
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

Check out DOMDocument() and DOMXPath()

Unimportant 18 Junior Poster

Float is to short
What double is to long

A float stores 1/2 the bits of a double
A double is a 64bit number, a float is 32bits like an int, but some of its storage is used for the decimal point.

Use double, although with a number as small as 1000 or even 10,000, I highly doubt float would give you any problems.

Unimportant 18 Junior Poster

If minutes < 10
std::cout << "0"

???

Unimportant 18 Junior Poster
using namespace std; // don't
 
const double Pi = 3.1415; // why not 3.1416 (3.14159)
int main() {
  master z01;
  double r;
  std::cout << "Please Enter A Radius \n";
  std::cin >> r;
  z01.setvalue(r); // setvalue is really ambiguous, consider changing function name
  std::cout << "The area is: " << z01.area() << std::endl;
  std::cout << "Press <ENTER> to end... " << std::endl;
  fflush(stdin); // consider removing these 2 lines and making the above a loop
  std::cin.get();
}
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

Make a function that blocks until year_seconds seconds have passed, where year_seconds is a variable you have flow control of, such that you can increase or decrease it at different phases of the evolution simulator you are creating.

Naturally, the process will typically finish in microseconds, so if you want to slow it down to 2 seconds, you need to actually force the program to wait.

Good luck!

Unimportant 18 Junior Poster

Why not just do exactly what you just said?
Just put if(type=='t') and then the rest of the code for that case.

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

I edited my post, please read it again.

a[-1] would -not- do what you are thinking, don't do that. At best it would be a[2^32] and crash your program due to access violation, and at worst it wouldn't compile. Or maybe the best/worst cases are opposite, who knows.

Just print the first 2 before your loop.
I'd also include 0 in your sequence for completeness.
If you want your range to be 10 numbers, change fN<=i to fN<=(i+1)

Unimportant 18 Junior Poster

Edit: My bad, I just re-read the code.
A fibonacci sequence starts with 0 for a reason, you omitted it.
Also, you print starting from a[2] (fN=2)

cout << a[0] << "\n" << a[1] << "\n";
for(fN=2;fN<=i;++fN) { // note that because fN starts at 2, the range from 2 - 10 is only 9 numbers including 10, use (i+1) if you want 1 more
  a[fN]=a[fN-1]+a[fN-2];
  cout << a[fN] <<"\n";
}
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

How is this a stack?

Do you just want to print a linked list?

Unimportant 18 Junior Poster

@csurfer, read the rest of my post.
I did that on purpose, and then used the modulus operator to add 1 to hours if minutes does not divide evenly into 60.
241/60 AS INT -> 4
241%60 != 0 -> 4 becomes 5

but if number of minutes was 240:
240/60 is still 4
240%60 == 0 -> 4 stays 4

if the number was 239
239/60 is 3 as int
239%60 != 0 -> 3 becomes 4

Also, please use code tags to preserve tabs

if (type == 'C') {
  cout <<"\nMinutes Parked: \n";
  cin >> num;
}
if ( num <= 120 ) {
  cout << "Free Parking\n";
} else {
  total = (num-120)/60; // don't know what the 1.75 was about
  if( num%60!=0 ) ++total;
  cout << "Total: " << total << "\n";
}

Edit: You can probably even drop the != 0, and use the line:

if(num%60)++total;

Due to the fact that 0 evaluates to false, and any other value evaluates to true, but this might be less clear readability wise.

Unimportant 18 Junior Poster
int hours(minutes/60);
if( (minutes%60) > 0 ) ++hours;

Divide minutes by 60 for the number of hours, the conversion to the "int" type will floor the value (drop any decimal amount)
The % (modulus) operator returns a remainder of division. If your number of minutes is not divisible by 60, increase the number of hours by 1.

Unimportant 18 Junior Poster
int* getElements(int num) { // don't return "int" unless you cast to pointer later
  int *ptr; // this is a pointer to int
  ptr = new int[num]; // it is still a pointer to int, since the new array is of ints
  //Enter 5 numbers.
  std::cout << "Enter " << num << " numbers: ";
  for (int i=0;i<num;++i) {
    std::cin >> ptr[i]; // now we fill the array with ints
  }
  return *ptr; // and this pointer can be used as the array, which has no
               // real name of its own, just a place in heap memory
}
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
void bookInput::displaybook() {
cout<< "\tName:"<< title << " \t\t\tDate Published: " << date<< endl;
}

Why are you only inserting tabs? Maybe it only goes to a newline because it ran out of space on the right side. Just insert a newline if you want a new line.

void bookInput::displaybook() {
cout<< "\nName:"<< title << " \nDate Published: " << date<< endl;
}

Assuming this is windows.

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

q0[0] is an address + 0x00 (a base address, really), and what it points to is just an int. An int does not have enough space for 10 ints.

You'll need to memcpy if you actually want to copy the data.

Though, I'm not sure my solution is what the book is telling you to do, so lets back up a second.

You have made 2 distinct arrays (although one of them only contains 0 for each element), but you know, you can use the pointer q1 like this:

q1[0];

Don't you think it might be hinting for you to do that inside of a function, where you pass q1? You could also pass the address (by reference) of the beginning of q0 (&q0[0])

Good luck!

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

I'd recommend you start by reading "Why's Poignant Guide to Ruby", it was my first introduction to the language as well. I found to be exceptional.

After that, "Rails Recipes" and "Advanced Rails Recipes" are great books.

Why's guide is free to download, the other two you have to buy. If you want some website references www.ruby-lang.org has many recommendations.

Best of luck!

Unimportant 18 Junior Poster

You can easily do it with a for loop, or any method of iteration.
You could also track that information as soon as it is input, so that no iteration is necessary. (update average and total number)

If you want more help than that, you'll have to post some of your code, good luck!

Unimportant 18 Junior Poster

int *p1 = p0[0];

Unimportant 18 Junior Poster
require 'net/smtp'
$message = ''
file = File.new("file_path_name_etc.txt", "r")
  while (line = file.gets)
    message << "#{line}"
  end
file.close
Net::SMTP.start('smtp.domain.com', 25) do |smtp|
  smtp.open_message_stream('from_addr', [to_addr]) do |f|
    f.puts 'From: youremail@address.com'
    f.puts 'To: recipient@domain.com'
    f.puts 'Subject: your subject'
    f.puts message
  end
end

## Pretty much sums it up, minus the calls to sleep, but ruby scripts can be run as
## services/daemons, you could also call it as a cron, or have it check the time
## while running.

### AUTHENTICATION ### REPLACE THE LINE ABOVE THAT HAS SMTP.start
# PLAIN
  Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain','ACCOUNT', 'PASS', :plain)
  # LOGIN
  Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain','ACCOUNT', 'PASS', :login)
  # CRAM MD5
  Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain','ACCOUNT', 'PASS', :cram_md5)

Good luck!

Unimportant 18 Junior Poster

I'm not really sure what you think the code you have means, but to me it is a little bit silly.

void mystring::reserve(size_t n) {
  if(!n>buf_size) return;
  char *swap = new char[n]; // also it's better to use powers of 2 to prevent overhead
  memcpy(swap,ptr_buffer,buf_size); // copy the old data
  buf_size = n; // this is the new maximum occupancy of the array
  delete[] ptr_buffer; // delete the old array, as it will soon just be random memory
  ptr_buffer = swap; // change your char* to the address swap points to
  // which is the array we just allocated and copied the old contents into
}

You really need to read up on pointers and dynamic memory.
Good luck!

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

I know this is a C++ forum, but why don't you just do this in Ruby?

Otherwise, make a thread that sleeps for 60 seconds and increments a counter by 1, when the counter is 120 (2 hours), reset it to 0 and execute the file read.

Save the file to a variable and then send an email with winsock. There are myriad socket libraries with tons of functionality, such as the boost socket library.

If you do this in the Ruby language, the program will be under 10 lines of code.

Good luck!

Unimportant 18 Junior Poster

#include <fstream>

Unimportant 18 Junior Poster

pow(base,exp);
pow((double)hT,3); // 3rd power

Unimportant 18 Junior Poster

Yes.