Dogtree 23 Posting Whiz in Training

>> How do they make tables with only CSS without using HTML Tables?
Well, if you need a table, you need a table. But you can do typical table layout stuff with CSS pretty easily. Just make good use of divs.

>> is it possible to make a table as shown on the screenshot below with only CSS and NO HTML?
Absolutely! You can do it a bunch of ways. Probably the easiest would be something like this.

<div>
  <span class="box-title">Title Stuff</span>
  <div class="box">
    <ul class="box-list">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li>Item 4</li>
    <li>Item 5</li>
    </ul>
    <span class="box-link">Link&gt;&gt;</span>
  </div>
</div>

Then the CSS is a simple div with carefully crafted borders and a float for the "title" element. Then inside the div is just a bullet list with a cut left margin and link below it with a large left margin.

.box {
  width:5em;
  border:solid #0000FF;
  border-top-width:1.5em;
}

.box-title {
  float:left;
  margin-left:.2em;
  margin-top:.3em;
  color:#FFFFFF;
}

.box-link {
  padding-top:-1em;
  margin-left:2em;
  padding-right:.2em;
  padding-bottom:.2em;
}

.box-list {
  list-style-type:circle;
  margin-left:-2em;
  margin-bottom:.5em;
}

With tweaking you can make it more elegant, of course. ;)

Dogtree 23 Posting Whiz in Training

>> I mean like the PYTHON , you can see a nice topic ( Starting Python) in this site , i mean like that .
A good tutorial is hard to write. It takes a lot of time, and the people who know enough to write a good tutorial probably don't have enough time to do it. You should look for existing tutorials instead of waiting for something new to be written.

Dogtree 23 Posting Whiz in Training

>> which of the above methods is better in implementing .....
It depends.

>> what are the advantages of recursion over iterative methods ??
http://www.stanford.edu/~blp/writings/clc/recursion-vs-iteration.html

Dogtree 23 Posting Whiz in Training

I have done plenty of research on this factor and many huge websites (including this one) do not work on 800*600 screens. This includes sites also like Yahoo.

That's irrelevant. Unless you cater to high tech people who are more likely to be using a high resolution, the majority of your hits will be people who use 800x600 as the default resolution. When people are forced to side scroll, they tend to leave the site and never return. It's completely your decision, of course, but I'm not of the opinion that we can abandon 800x600 users just yet. Give it a few more years. ;)

>> but I would really appreciate a clear answer on how to do it.
Without getting into some serious Flash, you can use Javascript to test for the screen width and redirect the parent page to an appropriately designed page for that resolution.

if (screen.width < 1024) {
  parent.location.href = 'mylowrespage.html'
}

You could also do the same thing with multiple images of different sizes, since the only problem you're having seems to be the background image.

Dogtree 23 Posting Whiz in Training

>I wanted to know how I should go about designing the webpage.
Design and implementation are different. Start by deciding what you want your site to accomplish. Look at sites that do the same thing and try to get a feel for what kind of user features you need or want to add. It's a good idea to look for style guidelines and design tips so you don't make the same mistakes that so many people have made in the past. This is especially important since you're shelling out for a domain and a host. People using free services can get away with the Geocities complex, but if you're actually paying for a domain and host, or supplying one yourself, you have no excuse for a crappy design. ;)

>I have the Microsoft frontpage program
Rule #1) Don't use Frontpage. It sucks ass. The ideal would be to start learning with a straight text editor like Notepad or Textpad. That way you don't end up using web design convenience features as a crutch. In my opinion, if you can't write the code manually, you shouldn't be doing it with a RAD or WYSIWYG system. If you're anything like me, you'll end up working primarily with the code regardless of the software you use anyway (I use Dreamweaver).

>I do not know how to tranfer that design to the actuall website domain
You don't transfer web pages to a domain. The domain name is nothing more …

Dogtree 23 Posting Whiz in Training

>>Because I am pretty sure my site will look really bad on anything apart from a 1024*768 or 1280*1024.
Then it has critical design flaws. If you don't design for people at lower resolutions too, your site is probably doomed to failure. At the very least, you should support a screen resolution down to 800x600.

Dogtree 23 Posting Whiz in Training

So you deliberately break the type system and then wonder why it doesn't work? :) What were you expecting to happen?

Dogtree 23 Posting Whiz in Training

Yes, you have posted a good class but can u give main() function code also, how to call the class and which member function. Means how to read the file (.CSV) and pass in the object of class and get the parsed content as output.

In that case, you need to ease off on your project and do something closer to your current skill level. If you can't figure out how to use such a simple class, you're not even close to being ready to parse CSV files and write MFC apps.

Dogtree 23 Posting Whiz in Training

>> can u give send me some code how to seperate the contents from commas.
That nice convenient class I posted that does exactly what you asked for must not have been what you really wanted. Why are you using char arrays anyway? How archaic!

Dogtree 23 Posting Whiz in Training

It's just what the error says. You can't have that particular debugging switch active when optimizing for speed. Under your project settings, the general tab in C/C++, you can change Debug Information Format to disabled.

Dogtree 23 Posting Whiz in Training

>> Extent of CSV format is like
Well that's simple enough. You don't need to do any tricky parsing if there won't be commas embedded in a field.

#include <sstream>
#include <string>
#include <vector>

using namespace std;

class ParseCSV {
public:
  typedef vector<string>::const_iterator iterator;

  ParseCSV() {}
  ParseCSV(const string& record) { assign(record); }

  void assign(const string& record);

  iterator begin() const { return split.begin(); }
  iterator end() const { return split.end(); }
private:
  string trim(const string& field);

  vector<string> split;
};

string ParseCSV::trim(const string& field)
{
  string::size_type start = field.find_first_not_of(" \t\v");

  return field.substr(start, string::npos);
}

void ParseCSV::assign(const string& record)
{
  stringstream recStream(record);
  string field;

  split.clear();

  while (getline(recStream, field, ','))
    split.push_back(trim(field));
}
Dogtree 23 Posting Whiz in Training

The only way I can think of would be to munge the address. The problem with that is people can't click on it anymore and be able to mailto. A spam crawler can just as easily check your source as it can your page contents, so any email addresses would need to be specifically represented so only a human being with half a brain can transform them into something legit. dogtree@dogtreestudios.com would become dogtreeYOUKNOWWHATTOADDdogtreestudiosDOTNESScom.

Dogtree 23 Posting Whiz in Training

So you want a fixed, non-repeating image, that changes size when the browser window is resized? I don't think you can do that with portable CSS.

Dogtree 23 Posting Whiz in Training

What's the extent of your CSV format? Is it just a bunch of fields separated by commas, or can the fields contain commas as well? A full CSV format means you need to do some tricky quotation parsing if a field needs an embedded comma.

Dogtree 23 Posting Whiz in Training

Kinda sorta. My company had an office in New Orleans, but thankfully none of the equipment I'm in charge of was drenched (no one was hurt either, so I'm not being callous). I do have the issue of recovering it for use elsewhere though. My primary concern is disease. The CDC hasn't been helpful at all about how to clean up a computer so that it can be reused and if someone pulls out a fan, the whole office doesn't get some nasty disease.

Does anyone have any tips on cleaning up electronic hardware that's been sitting around a pool of stagnant, disease-ridden water for three weeks?

p.s. I got to wear a hazmat suit! How many IT pros can say that, eh? :D

Dogtree 23 Posting Whiz in Training

> Please some one write this program
No. If you're too lazy to do it then you deserve a failing grade.

Dogtree 23 Posting Whiz in Training

> spans of whitespace?
Whitespace is when you hit the space bar on your keyboard, or the tab key, or the return key. Spans means one or more. So you're looking for one or more of ' ', '\t', '\n', or '\v'.

Dogtree 23 Posting Whiz in Training

> How very true, but STL is chapter 10. I'm at chapter 6
What are you talking about? The STL has nothing to do with redirecting the output of a program to a file from the shell. If you were talking about the vector suggestion then you really need to work on formatting your quotes so that it's obvious which quote goes with which question.

> can you tell me in wich type of programs you use STL regularly
All of them.

> Understood, only, what do you mean with the expression "from the shell"?
Shell, terminal, command line, that black thingy with white text that you type and it does stuff.

Dogtree 23 Posting Whiz in Training

The height attribute doesn't exist in any portable HTML specification. You're relying on an IE extension. A workable solution is CSS:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type="text/css">
html,body {
  margin:0;
  padding:0;
  height:100%;
  width:100%;
}

table.full-height {
  height:100%;
  width:100%;
  border:1px solid black;
}
</style>
</head>
<body>
  <table class="full-height"><tbody><tr>
    <td>This is a test</td>
  </tr></tbody></table>
</body>
</html>
Dogtree 23 Posting Whiz in Training

One word: Javascript. A quick google search will give you something like this.

Dogtree 23 Posting Whiz in Training

To count the number of words, just count spans of whitespace. Each span of whitespace separates a word. To count the number of sentences, look for punctuation.

Dogtree 23 Posting Whiz in Training

> Would it be something like this then?
Something like that, yea. But wouldn't it be faster to try it out for yourself? ;)

> Also, do I need to use forward or backward slashes?
Either will work from the shell. The only issue with back slashes is in C++ where they are the escape for special characters in string literals.

Dogtree 23 Posting Whiz in Training

As one would expect, the page will look funky if you try to create a fluid layout and then shrink the viewing area so that it's smaller than the collective width of your images. There's really no solution except to assume a minimum width and design for it.

Dogtree 23 Posting Whiz in Training

> Do I have to enter the same path wich it has to follow as in the other ones?
Yes. For simplicity, my example assumed that both the executable program and the file were local to the root directory C:\, but unless your current working directory is the same as the executable and the output file, you need to specify an absolute path.

Dogtree 23 Posting Whiz in Training

> Which approach below is faster?
Generally, if you're working through a pointer, there's an extra level of indirection. Therefore, in theory, going indirectly though a pointer is slower. In reality, if the compiler doesn't optimize the difference away, it'll be infintesimally small. So you should use whatever more clearly shows your intentions.

Dogtree 23 Posting Whiz in Training

> In other words, it means that *pp has those properties wich are mentioned in the structure right
Yea, basically.

> And can only a pointer have that ability to be written in that place
No, you're just declaring a variable. It's the same thing as this:

struct row
{
      int *col, size;
};

row *pp;

> What is the difference then when writing a structure, like this
pp is local to main in the first example, but has file scope and external linkage in the second.

> Could you tell me how I can make it redirect towards the output of a file?
If you run the program from the command line you can do this:

C:\> prog > file
C:\> type file

Or you can redirect to a file from directly in within the program. First by using the file stream instead of cout:

#include <fstream>

int main()
{
  std::ofstream out("file");

  out << "output\n";
}

Or by re-assigning the stream buffer of the file stream to cout:

#include <fstream>

int main()
{
  std::ofstream out("file");
  std::streambuf *saved_buff = std::cout.rdbuf();

  std::cout.rdbuf(out.rdbuf());

  std::cout << "output\n";

  std::cout.rdbuf(saved_buf);
}

> Well, I guess it depends on what you call simple right
Yea. :mrgreen: Simple for me may not be simple for you, and vice versa depending on the problem. Nobody knows everything. :)

Dogtree 23 Posting Whiz in Training

Hey, the code is correct, so you're ahead of most of the tutorials on the web these days. ;)

[edit]
Your site is bookmarked. I'll consider joining.
[/edit]

Dogtree 23 Posting Whiz in Training

> First of all, open your C++ compiler.
This assumes that you're using an IDE and not a command line based compiler. For the latter you would open a text editor, and the compiler wouldn't be invoked until after the code was written.

> This code tells the program to include the IOSTREAM and CSTDLIB header files within the program.
What are these IOSTREAM and CSTDLIB things you're talking about? C++ is case sensitive, so you'll just be confusing the reader. The standard headers are also not required to be files, so 'header files' is a misnomer.

> This tells the program to use the STD Namespace.
That's the std namespace, not STD.

> A namespace creates a declarative region in which various program
> elements can be placed. Elements declared in one namespace are seperate
> from elements declared in another.
I don't think a beginner will really follow you on this one. ;)

> Using the STD Namespace simplifies access to the C Standard library (cstdlib).
Why?

> The COUT part, stands for console output.
Actually, it stands for character output. Many people mistake the c for meaning console because cout is almost always directed toward a screen device of some form, but it doesn't need to be.

> It simply prints the text "Hello, World!" on the screen.
So just typing this in will print the text? I don't have to do …

Dogtree 23 Posting Whiz in Training

You're thinking too hard. :)

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>

int main()
{
  const char InputFileName[] ="in.txt";
  const char OutputFileName[]="out.txt";

  std::ifstream InFile(InputFileName);
  std::ofstream OutFile(OutputFileName);

  if (!InFile || !OutFile) {
    std::cerr << "File open failure\n";
    std::exit(EXIT_FAILURE);
  }

  std::string name;
  int age;

  while (InFile >> name >> age)
    Outfile << name << ' ' << age << '\n';
}
Dogtree 23 Posting Whiz in Training

> Can you please provide me with examples of when and how copy constructors are used..
The simplest example is passing an object by value:

class C {};

void foo(C obj); // C's copy constructor is called
Dogtree 23 Posting Whiz in Training

> Is it right ??
No, you're thinking that the left side of my queues designate the front, which wasn't the intention. It works like this in the example that I gave:

New values go in here -> 1 2 -> Old values come out here

If you want to think of it the other way around, that's okay too, just reverse the values.

Dogtree 23 Posting Whiz in Training

1) No, a structure's members are public by default, so anyone can access them. Dave put the structure in main to limit its scope to main. Consider this:

int main()
{
  struct test {};
  test t; // Okay, test visible
}

int foo()
{
  test t; // Error! test not visible outside main
}

2) That's a declaration of pp, a pointer to struct row. You can split it up by the type and the identifier, and compare it with an integer to see the similarities:

Type                            Identifier
------------------------------  ----------
struct row {int *col, size;} *  p;
int                             x;

The only difference is that int already exists while struct row is being defined.

3) You can cut and paste from the output medium, such as the console, or redirect the output to a file. It really depends on your system and compiler.

4) Dave's solution makes use of simple objects. Each row object has an array and also stores the size of that array. In all but the most trivial of programs, this solution has the benefit of simplicity.

Dogtree 23 Posting Whiz in Training

Think of it this way: For each new value that's pushed onto the 'stack', you pop all of the values from queue1 onto queue2, then push the new value onto queue1. Taking a simple example, say you have queue1 with a single value, 1, and you want to push 2 onto it so that the next pop gives you 2 instead of 1:

queue1: * 1
queue2: *

Empty queue1 onto queue2:

queue1: *
queue2: * 1

Push 2 onto queue 1:

queue1: * 2
queue2: * 1

Then empty queue2 onto queue1:

queue1: * 1 2
queue2: *

So now, by pushing 1 and then 2 onto the queue this way, popping them both off would give you 2 1, just like a stack, instead of 1 2, like a queue.

Dogtree 23 Posting Whiz in Training

Start a new thread, dude. It's bad form to bring an old thread back from the dead.

Dogtree 23 Posting Whiz in Training

That's all well and good, but you didn't answer the original question. You just threw away the code given and posted a C-style solution with the implication that it was somehow better, without explaining why, when there are very good arguments for avoiding such a solution until one knows what is gained and what is lost with the decision.

Dogtree 23 Posting Whiz in Training

> and I dont have a complier
I suggest you get one, because your code will not compile. Or at the very least, you can test drive Comeau here to see what the errors would be.

Dogtree 23 Posting Whiz in Training

1) You're using the margin:auto trick, right? IE can have issues with that, especially older versions. Though the site looks fine for me in IE6. A common hack to fix that is to use text-align:center on the box rather than the text.

2) If you want to use CSS for it, wrap everything in a div and center the div.

Dogtree 23 Posting Whiz in Training

> why is this more elegant?
C-style I/O doesn't recognize the std::string class, so you end up having to jump through error prone hoops to get it to work, or you need to use C-style strings, which are inherently error prone. That alone is reason to use iostreams. If you don't understand how to use iostreams, or you like C-style I/O better, that's okay. But please don't try to convince other people to take a big step backward in safe programming practice when they're still learning the basics.

@simplex85:

You have issues with your program. First, you try to print uninitialized variables. That results in undefined behavior, and you really want to avoid undefined behavior. Since printing out the scores when you haven't read any is nonsensical, you can remove that part of the program.

> while (infile >> studentname);
Notice the trailing semicolon. That means that the loop will read names until there's an input error, or the end of the file is reached. In other words, it's not doing what you think it is. Remove the semicolon.

{
  calculatescore();
  average = total / 10;
}

There's no need for braces here.

I don't know why you thought that calculatescore does anything meaningful. You would be better off avoiding functions until you know how to make them communicate with main.

> int q1,q2, q3, q4, q5, q6, q7 ,q8 ,q9 ,q10;
When you number variables like this, it's a sure …

Dogtree 23 Posting Whiz in Training

Dude, this thread is well over a year old. Next time, if you have a new question, start a new thread.

To save an array to file, just open the file, then loop over the array and write each element in turn:

#include <fstream>

int main()
{
  std::ofstream out("somefile");
  int array[] = {0,1,2,3,4,5,6,7,8,9};

  if (out.is_open()) {
    for (int i = 0; i < 10; i++)
      out << array[i];
  }
}
Dogtree 23 Posting Whiz in Training

> I did this because The code was to long DUDE is two files
That's where you make it smaller so that it's suitable for posting. You know, cut out all of the fluff so that just the necessary stuff and the errors are still there. Most of the time just doing that helps you solve your own problem without posting.

> warning C4996: 'kbhit' was declared deprecated
That's a Microsoft-ism. In their infinite wisdom, the creators of Visual Studio decided to mark random functions as unsafe and deprecate them with this warning. In the real world, nobody cares, so you can ignore that warning.

> error C2561: 'Game::timerUpdate' : function must return a value
This is pretty self explanatory. You say that timerUpdate will return bool, but you don't return anything. Either return true or false, or change the return value to void.

Dogtree 23 Posting Whiz in Training

It's best to assume that we're all overly paranoid. I'm not going to download anything from your site unless you can prove to me that it's completely harmless. The best way to do that is to post code and ask a detailed question about that code here. Otherwise, you probably won't get much help from anyone smart enough to be paranoid.

Dogtree 23 Posting Whiz in Training

Your version? No offense, but I would rather use Open Office than wait for some unnamed clone from some unnamed author to be released and 'take over the market'. Unless of course you can show a working and promising start that is comparable to Office or Open Office.

Dogtree 23 Posting Whiz in Training

> Containment is the same as composition?
Yes.

> can I create an instance of one class within or from another?
Of course.

> Can I modify a previusly constructed object?
As long as it isn't const, sure.

Dogtree 23 Posting Whiz in Training

This has nothing to do with C or C++. Try posting in the Windows help forum. You'll probably get better answers than we could provide.

Dogtree 23 Posting Whiz in Training

In that situation, you make the operator inline. The correct way to define it outside of your class is way too awkward to be practical:

#include <iostream>
using namespace std;

template <typename T, int SIZE> class array;
template <typename Ty, int sz>
ostream& operator<<(ostream& out, const array<Ty, sz>& ar);

template <typename T, int SIZE>
class array
{
  T data_[SIZE];
  array (const array& other);
  const array& operator = (const array& other);
public:
  array(){};
  T& operator[](int i) {return data_[i];}
  int getSize() {return SIZE;}
  const T& get_elem (int i) const {return data_[i];}
  void set_elem(int i, const T& value) {data_[i] = value;}
  operator T*() {return data_;}  

  friend ostream& operator<< <>(ostream& out, const array& ar);
};            

template <typename T, int SIZE>
ostream& operator<<(ostream& out, const array<T, SIZE>& ar)
{
  out<<"< ";
  for(int i=0;i<SIZE;i++) 
    out<<ar.data_[i]<<" ";
  out<<" >";
  return out;
}

int main(void)
{
  array<int, 10> intArray;
  for(int i=0;i<10;i++) intArray.set_elem(i, i+100);
  //std::cout<<" element 0: "<<intArray.get_elem(0)<<std::endl;
  //int firstElem = intArray.get_elem(0);
  //int* begin = intArray;
  cout<<intArray;
}
Dogtree 23 Posting Whiz in Training

> I have no idea what I'm doing.
Clearly. You have serious design problems by using inheritance instead of containment for this project. It's much simpler if CartesianPoint (aside from being more concisely named) is a self-contained class, then Line and LineSegment contain CartesianPoint (henceforth to be referred to as Point) objects:

class Point {
  int _x, _y;
public:
  Point(int x, int y);
  void set(int x, int y);
  int getx() const;
  int gety() const;
}

class Line {
  Point _start, _finish;
public:
  Line(const Point& start, const Point& finish);
  void print() const;
}

// etc...

Much easier, and more intuitive. :)

Dogtree 23 Posting Whiz in Training

operator<< doesn't need to be a friend since you only use the public interface of array in it. A non-member function only needs to be a friend if it has to have access to a classes private or protected members.

#include <iostream>
using namespace std;

template <typename T, int SIZE>
class array
{
  T data_[SIZE];
  array (const array& other);
  const array& operator = (const array& other);
public:
  array(){};
  T& operator[](int i) {return data_[i];}
  const int getSize() const{return SIZE;};
  const T& get_elem (int i) const {return data_[i];}
  void set_elem(int i, const T& value) {data_[i] = value;}
  operator T*() {return data_;}
}; 

template <typename T, int SIZE>
ostream& operator<<(ostream& out, const array<T, SIZE>& ar)
{
  out<<"< ";
  for(int i=0;i<ar.getSize();i++) 
    out<<ar.get_elem(i)<<" ";
  out<<" >";
  return out;
}

int main(void)
{
  array<int, 10> intArray;
  for(int i=0;i<10;i++) intArray.set_elem(i, i+100);
  //std::cout<<" element 0: "<<intArray.get_elem(0)<<std::endl;
  //int firstElem = intArray.get_elem(0);
  //int* begin = intArray;
  cout<<intArray;
}
Dogtree 23 Posting Whiz in Training

Ouch. Sounds like a serious corruption. You can try a live Linux CD like Knoppix to recover the data, but it's possible that it's a loss unless you want to pay for expensive professional recovery.

Dogtree 23 Posting Whiz in Training

You seem confused about the difference between threads and processes. To use processes you fork a child from a parent and use one of several methods for inter-process communication. To use threads you say the magic incantation:

$ man pthread

Multiple processes don't share memory, so you're required to bend over backward to have them communicate. Multiple threads do share memory, so that's easier, but also more dangerous right out of the box because you risk two threads writing to the same memory at the same time.

Dogtree 23 Posting Whiz in Training

> the question is why not doing this using C ?
Because C doesn't provide native support for crawling the web, and there aren't any commonly used libraries for it. In the time you would take to find a library to do what you want and learn it, you could have written, tested, and debugged something workable in Perl.