Bench 212 Posting Pro

Hi,

i would like to separate the declaration of a class from the definition.
i know about the

void aclass::a_method(){ ..... }

but i dont know anything about what should be written in the header file, and how can i use it through main....:confused:

sorry if am not very specific but i don't how to express it...
Can anyone suggest a link for further reading...or maybe explain with an example....:)

thanks in advance....

In a header file (generally, a file with an extention of .h or .hpp), the most common approach is to declare classes/functions/etc without providing a definition. Then with a .cpp file of the same name, you provide the definition. eg,

//foo.h

class MyClass
{
    int blah;
public:
    MyClass() : blah(0) {}
    int get_blah();
}
//foo.cpp
#include "foo.h"

int MyClass::get_blah()
{
    return blah;
}

You can #include the into your code header the same way as any other library or header file - making sure you provide its path if the header is inside a different directory.

Edit: The above is somewhat incomplete - you should include header guards to stop the file being included twice, ie,

//foo.h
#ifndef FOO_H
#define FOO_H

class MyClass
{
    int blah;
public:
    MyClass() : blah(0) {}
    int get_blah();
} 

#endif

The 3 lines highlighted in purple take advantage of the preprocessor, to ensure that everything inbetween the #ifndef and #endif directives can only ever be included once (to include the header file more than once will almost …

Bench 212 Posting Pro

IEEE 1394 is better known as Apple's "firewire" - I have no idea why Windows would think its connected to something. IMHO, the best thing you can do with that adapter is leave it disabled in Device manager, unless you happen to own a device which needs it... Better still, maybe disable it in your BIOS configuration altogether.

Unicast, Multicast and Broadcast refer to the destination of a signal over the network - a unicast signal is intended for a single destination only (given a single destination address). Multicast is a signal intended for multiple destinations within a network ( the signal has multiple destination addresses) , wheras broadcast is all destinations on a network (Network address schemes such as IP have a special reserved broadcast address).

For a network with just one other computer, I can't see that it makes any difference which one you use (broadcast might be easier to setup, but that depends on the software).

Bench 212 Posting Pro

What's the configuration of the machine you are trying to ping from?

One problem which jumps out immediately is that the default gateway of your wireless interface is on a different subnetwork to the IP address of the machine.

Ethernet adapter Wireless Network Connection:

Connection-specific DNS Suffix :
Ip address : 10.65.26.231
subnet mask: 255.255.255.0
default gateway : 10.65.24.1

Either change the IP address to one which is on the 10.65.24.0 subnetwork, or, use a gateway which is attached to the 10.65.26.0 subnetwork.

This should only affect ping attempts which go to addresses outside the 10.65.24.0 subnetwork - Have you tried sending a ping from a host within the 10.65.24.0 subnet?

Bench 212 Posting Pro

Suppose a pulse generator gives out signals as a stream and we need to count the numberr of pulses... then how do we do that.

Are you actually capturing data from this device? or is it a make-believe example where you have to simulate the data capture?

simulating data capture should be easy - just read some data of your choice from the keyboard, and process it bit by bit as the pulses are read (the usual choice for representing digital input such as electromagnetic pulses is 1 and 0, but you could use anything)

A loop would be useful for determining when data capture is finished. You could use selection (eg - if/else) to determine whether the input is "on" or "off".

If there is a real device which you're reading from, then it still may be a good idea to start your program with simulated keyboard input where you are controlling the input - this means you can get that part right before you attempt to combine it with your real data capture code.

Bench 212 Posting Pro

how about a competition for most obfuscated :)
C++

#include <iostream>

int main()
{
    int _0(0);
    while("\"#$%&\'()*+,"[_0]!=',')
        std::cout<<static_cast<int>("\"#$%&\'()*+"[_0++]-'!')<<" ";
}
Bench 212 Posting Pro

I need some help,Here is the problem, I work for a company that lays ceramic floor tile and I need a program that estimates the number of boxes of tile for a job.

Somehow I don't believe you... Why not just admit that this is your homework?

One simple way to check for valid inputs (essentially ask the user again if the input is invalid) is to put your 'get' code inside a do..while loop. You could wrap it in a function aswell if you wish, for example:

#include <iostream>

int get_number_between(int lower, int upper)
{
    int in;
    do
    {
        std::cout << "Enter a number between " << lower << " and " 
            << upper << " inclusive:";
        std::cin >> in;
    }while ((in < lower) || (in > upper));
    return in;
}

int main()
{
    int x = get_number_between(0,100);
    std::cout << "User entered: " << x;
}

This isn't a perfect solution, and will invoke undefined behaviour if the user enters anything other than a number, although it provides a very basic form of input validation. You could improve it by adding checks on the state of the stream aswell.

Bench 212 Posting Pro

Both network connections work completely independently of each another (meaning that any settings you have for one connection won't apply for the other, and neither connection can "see" the other - however, since they are different networks, they must be given different IP address ranges) - so I suspect you just haven't configured the local connection to use whichever services you need (eg file & print sharing)

Are you able to "ping" the other computer across the local connection from the windows console? if so, the network is working fine. If you've not set up static IP addresses for either of the machines, you can find out their IP address by typing ipconfig in the console window.

By default, windows usually installs the file & print sharing service, but not the NetBIOS service, which File & print Sharing requires to communicate over the network.

In windows network properties, have a look for the configuration of your Local network (Leave alone the configuration for your cable/DSL, since that's obviously working properly!) - and find the properties for the TCP/IP protocol in the Local network.

Inside TCP/IP settings, find the 'Advanced' settings. Then go to the WINS tab, and change the radio button for NetBIOS to 'enable NetBIOS over TCP/IP'

Provided that your network is functional, and you don't have conflicting IP ranges between the two connections, This should allow all the normal windows file & print sharing services to work properly over the local connection.

Bench 212 Posting Pro

what is the type of "int position(3) ", different from "int a[3]"

Yes, those are completely different! the line int position(3); does the same thing as int position = 3; In case you're wondering why I used the ( ) instead of assignment operator for built-in types is something of a style issue. Personally, I find it more idiomatic to initialise variables using the 'constructor' initialisation syntax rather than the assignment syntax. YMMV, sorry for the confusion :)

Bench 212 Posting Pro

but how to use pointer to move the reading postion? point to what?

Imagine file access is like an old fashioned mono-directional cassette tape player (ie, no rewinding!) - the only way to find the position of a chunk of data is to play through the tape from the start, and read each chunk of data sequentially.

The chunk of data you read is always at the "head" position - The tape moves forward, rather than the head (and since you can't rewind, the data which has already passed the head is gone from the stream). You can choose to either store the data at the head or discard it. The tape rolls on once the head has read whatever's at that position. Whatever you do, you *must* read it in order to move the tape on.

here's a quick example of reading the 3rd word in a stringstream (Which is just another 'flavour' of streams - fstreams work in exactly the same way)

#include <iostream>
#include <sstream>

int main()
{
    std::stringstream ss("the quick brown fox jumped over the lazy dog");
    std::string str;
    const int position(3);

    for(int i(0); i!=position; ++i)
        ss >> str;

    std::cout << str;
}

This example outputs the word "brown" - the first 2 words, "the" and "quick" were also read, but discarded, since the only word I was interested in was the 3rd one.

Bench 212 Posting Pro

I hav no idea fnd.....pls share u r views.........

Someone has already provided you with a rough outline of the program as a starting point.
Perhaps you missed this on your way in..? http://www.daniweb.com/techtalkforums/announcement8-2.html

Bench 212 Posting Pro

yes,but that is read one line.
how to jump to the second line?

you can't "jump", file access is serial. if you need a certain position, read the first line(s) and discard it/them until you reach the position in the file that you need.

Bench 212 Posting Pro

Reading from a file works the same way as reading from any other istream, such as cin:

//read up to newline
std::string str;
std::getline(cin, str);
//read up to whitespace (after a word or character)
std::string str;
cin >> str;

With files, replace cin with the name of your ifstream

Bench 212 Posting Pro

writing pseudocode and problem solving is all part of programming & software development (And if you haven't tried to write pseudocode for this problem yet, then I suggest you give it a go, and see if that helps!), so I'm not going to write a complete comprehensive solution, although, its equally true that the best way to get your head around a problem you've been sweating over is to find a fresh brain to skim over it.

Here's how I would approach the problem:

What does the input look like? You should make sure you have this well-defined. the first hurdle might be string manipulation, eg, if you've got to extract several elements from a string such as "09:45am", then you probably want to search for the delimiter : which seperates the numbers, and extract the two numerical parts as ints, then extract the am/pm suffix to a String

Alternatively, you could leave that bit til last, and just have each part input seperately by the user - in which case, the problem should be more trivial. If your suffix is "am", then the hours remain the same. if your suffix is "pm", then you need to add 12 to your hours. minutes remain the same regardless, and the suffix isn't used in 24hr time.

Finally, what does the output look like? you could simply concatenate hours & minutes for 'military' time format, eg "2315", or perhaps add a seperator in the middle - "23:14".

Bench 212 Posting Pro

I was wondering if you had a wirless connection and a ethernet connection going at the sametime how dose the computer know which one to connect to or how dose if decide(IS IT FIRST COME FIRST SERVE).:confused:

It doesn't need to decide anything - You can be connected to both networks at the same time with no problems.

Bench 212 Posting Pro

Hello:

I was wondering if anyone in this forum could point me in a direction (a link) where I could find practice projects (similar to Python Projects for the Beginner) dealing specifically with C++ classes and their related functions?

Thank-you in advance,
reRanger

Why not use some of the suggestions in that thread? most of the suggestions there could be suitable for just about any general purpose programming language (ignoring the PyGame stuff, even then, you could probably make simplified non-PyGame versions).

Bench 212 Posting Pro

Hi,

I have a question which i have no idea how to do manage.

I need to convert a string in the format like "1 234 567" so i can do some calculations on the indvidual numbers.

What is the best way to do this?

Thanks

Are you using C++ or C? if you're using C++ then investigate stringstreams, which can be found in the <sstream> library - stringstreams make this sort of thing really, really easy!

Bench 212 Posting Pro

Just a few comments, since andor has already pointed out what appears to be the main problem.

usingnamespace std;

typo above, was that a result of colouring in the code? or didn't you copy&paste your code? as a general rule of thumb, never attempt to retype code, because typo's happen - making it hard to give helpful advice - paste it instead.

You've got the variables total and number_buffer declared global - you only need them inside your main() function - you can pass them around to functions if you need to (which you have done), so there's no need for them to be in the global scope. Using global variables is a bad habit, so good design avoids them whenever possible.

The header "stdafx.h" is unnecessary - something which MSVC++ uses when you have precompiled headers enabled. there are loads of hits on google which tell you how to disable precompiled headers.

Bench 212 Posting Pro

Your professor sounds like he's leading you up the garden path - the system() function takes one argument (a const char*) and returns an int, which, in all cases i'm aware of, is purely an indicator for whether or not the call was successful (0 for success, and non-zero for failure). The option of storing the output in a text file sounds like the best one by far.

Bench 212 Posting Pro

EDIT: I'm in shock! I'm sorry that my code is so similar to yours. It was a complete coincidence. :eek:

heh, I think you can claim that yours is a more OO version :)

Bench 212 Posting Pro

Since you're using C++, have you done any research into STL and the standard library algorithms? these sorts of tasks are exactly the kind of thing which the STL excels at doing - eg,

#include <iostream>
#include <vector>
#include <algorithm>

template<const int N>
int array_size(const int (&arr)[N] )
{ 
    return N;
}

int main()
{
    typedef std::vector<int>::iterator iter_t;

//Just for the purpose of this example, populating
// an STL vector container using an array initialiser.
    const int lookup_table[] = { 2,3,5,5,11,13,11 } ;
    std::vector<int> my_vec(lookup_table, 
                            lookup_table + array_size(lookup_table) );

//Sorting all elements in the container:
// Make sure that all elements in the container are in order
// so that std::unique can identify all duplicates.
    std::sort(my_vec.begin(), my_vec.end());

    iter_t new_end;
    new_end = std::unique(my_vec.begin(),
                          my_vec.end() );

//Now the container is too big and has some unwanted data at the end
// lets get rid of those unwanted elements.
    my_vec.erase(new_end, my_vec.end());

    for( iter_t it = my_vec.begin(); it != my_vec.end(); ++it)
        std::cout << *it << std::endl;
}
Bench 212 Posting Pro

Just been playing about with C++ Templates, and thought of this thread :)
(By the way, only 44 posts?! we can do better than that...! )

#include <iostream>

template<int i> void count()
{
    std::cout << i << std::endl;
    count<i+1>();
}

template<> void count<10>()
{
    std::cout << 10 << std::endl;
}

int main()
{
    count<1>();
}
Bench 212 Posting Pro

The binary-to-decimal link which Dave has given you is the 'C' way of doing things, which is fine, and you should learn to do it that way, although, C++ gives you a really nice easy way to do this - Using the <bitset> library. (a bitset is a container which only holds 1s and 0s)

#include <iostream>
#include <bitset>
using namespace std;

int main()
{
    const int i = 100;
    const int total_bits = sizeof(i) * 8; // The number of bits in 'i'
    bitset<total_bits> b(i);
    cout << b << endl;
}

and, slightly more complicated, but really just the same logic in reverse

#include <iostream>
#include <bitset>
#include <string>
using namespace std;

int main()
{
    unsigned long i;
    const int total_bits = sizeof(i) * 8; // The number of bits in 'i'
    const string s = "1100100";

    bitset<total_bits> b(s);
    i = b.to_ulong();  // turns 'b' into an unsigned long int
    cout << i << endl;
}
Grunt commented: Good-[Grunt] +1
Bench 212 Posting Pro

I'm actually not sure whether I should start with C, jump into C++ or bother learning the language at all. (mainly because of the massive time commitment)

I know I will be learning C++ for the next four years in university. But I also know you shouldn't blindly accept what school teaches you as Gospel. Countless articles on reddit talk are about how Java sucks, schools that teach it put out mediocre hackers, etc. etc.

If you're considering learning C purely as a grounding for C++, then please save yourself the wasted effort and skip 'C'. the two languages sometimes look similar at first glance (C++ inherited alot of the C syntax), but they are fundamentally completely different languages - even the "Hello World" programs you learn to write on day 1 for each language are completely different. (You've probably already written a "Hello World" in C, so here's a quick example in C++ to contrast)

#include <iostream>
using namespace std;

int main()
{
    cout << "Hello, World!";
}

I'd like to backup Grunt's reccomendations for Bruce Eckel's Thinking in C++, and Accelerated C++ by Koenig & Moo. Both excellent beginner's books. Also, C++ Primer by Lajoe, Lippman & Moo comes highly reccomended for beginners.

Francis Glassborow also has a book written for people with no prior programming or computer science knowledge, called You Can Do It. that's also an excellent book, but the compiler & libraries included with the book only work on Windows. (So learning from …

Bench 212 Posting Pro

Thanks very much for that code. Unfortunately, that wasn't what I need. I know how to work with int, but not with char. What I need is an explanationon how to work with char, not the code itself.
Thank you for the input. It was worthwhile.

Working with int is exactly the same as working with char. the only difference between int and char is that a char is 1 byte, wheras an int is usually bigger.

Bench 212 Posting Pro

Although you can change the Display modes at the top of the page, the default is Linear mode, but you can change to Threaded or Hybrid mode where the posts will appear in a different order.

Bench 212 Posting Pro

How would you do it on paper? Imagine you're back at infants school where they teach you how to add up using columns of hundreds/tens/units with a carrier at the bottom.

Bench 212 Posting Pro

2nd: You did not include <stdafx.h>

stdafx.h isn't part of standard C++, it's something which MSVC++ uses for precompiled headers.

Bench 212 Posting Pro

if you run this code in c++ you get the following error at the underlined part is where the problem is
: error C2143: syntax error : missing ';' before 'constant'
: fatal error C1004: unexpected end of file found
Error executing cl.exe.

What you've got there is barely C++ at all, it looks like C code, but with dozens of syntax errors. Perhaps your editor didn't copy/paste it properly, but i think you need to do several things..

(1) break your code down into smaller chunks - you can easily move alot of that into header files and test each each bit more modularly.

(2) fix all the syntax errors, eg, void help=F1*>() Whatever on earth that is supposed to be, its illegal in C and C++.
..or..
(3) if the syntax errors really are just a problem with your IDE's copy and paste, then try copying the code from a plain text editor instead (eg, notepad)

(4) get rid of all the superfluous output formatting, text colouring and other "funky" stuff, in order to narrow down your problem. All its doing is adding massive extra baggage to your code, which is already cluttered. that sort of thing isn't helping anyone debug it. You can always add it back in when you're sure the rest of your program works fine.

Bench 212 Posting Pro

Hope you will try to understand the way these things have been derived and put some more effort next time.

I very much doubt it, you just gave him a free lunch. The real problem with doing other peoples' homework is that they've put no effort into it themselves, so they don't actually learn anything, having not been through the learning processes of thinking about the answers to the questions, or research from textbooks & notes. In the long run, spoonfeeding like that is really a disservice to learners.

A few words to ponder for the OP, intended for Mathematics students originally, but I think it applies to anybody who claims to be in the process of learning something new.

Using a calculator isn't cheating.
Looking up the answers at the back of the book to see how they got there isn't cheating.
Cheating is pretending to understand when you don't.
That is when you are cheating yourself

Bench 212 Posting Pro

could someone please provide me with the answersd to the following c++ problems, they are simple problems which are probably an insult to most of your intelligence but i'm clueless and desperate.

More the fact that you obviously missed this post here.. http://www.daniweb.com/techtalkforums/announcement8-2.html

Bench 212 Posting Pro

I get a segfault when I run the following. Seems to fail at strcpy.

#include <cstring>
using std::strcpy;

int main()
{
    char * word = "word";
    strcpy(word, "what");
}

If I change char * word to char word[], it's fine. I thought that both declarations effectively do the same thing. What am I missing?

Thanks in advance.

They both do nearly the same thing. The version with a char * word = "word"; creates a pointer to the string literal "word". You cannot assign to or overwrite a literal.
eg, try compiling a program containing the line 5=7; and you'll get an error.

wheras the version with char word[] = "word"; creates an array of 5 characters in memory; 'w', 'o', 'r', 'd', '\0' . since the array is an object rather than a literal, its contents may be changed.

Grunt commented: Good -[Grunt] +1
Bench 212 Posting Pro

That depends exactly what part you don't understand. Essentially, your problem seems to be about looping through arrays, and performing some operation on each element. If you're not comfortable with arrays, then do a google search for array tutorials, or check:
http://www.daniweb.com/tutorials/tutorial1732.html
http://www.cprogramming.com/tutorial/lesson8.html
Here's one for 'C' Style strings, which are null terminated arrays of char
http://www.cprogramming.com/tutorial/c/lesson9.html
and one for looping
http://www.cprogramming.com/tutorial/lesson3.html

You might find it handy to bite a smaller chunk off your problem, and create a simple program to solve that. for example, write a program which takes a series of 1's and 0's, and outputs the number of 1's in that series.

Bench 212 Posting Pro

um WaltP whats haveing your code properly formatted mean?

Aside from code tags, It also helps using a clear & consistant coding style, and having it properly indented (something which your IDE will probably do for you). Things like that will not only help other people read your code, but also help you read it, and spot basic mistakes (such as a missing bracket or semicolon etc).

Bench 212 Posting Pro

Actully that is not true in all the cases.

Which is exactly the point i was making, there are no "always do" or "never do" rules. it depends entirely on the platform you're developing for

Bench 212 Posting Pro

Well forgive me for butting in, but here modularity is not an issue since he is not building a Library module but a small program.

As far as writing normal programs are concerned the coder should always be concerned with the best and the fast implementataion wrt to both memory requirements and speed.

But still this is just me, I thought just wanted to let you know.
Any constructive criticisms appreciated.

Modularity doesn't mean that its a library module, he means breaking a program down into smaller, more managable chunks. I agree that it doesn't matter so much for a small toy program, but since maintainability and readability are generally the 2 most important goals for any coder to aspire to (usually far more important than optimum speed & memory usage), its a good habit to get into.

Bench 212 Posting Pro

You can't return multiple values from a function, you probably want to pass your variables by reference instead. ie

void ReadInput (int& a,int& b)
{
	
	cout<<"Please enter flavour(1=choco,2=caramel,3=mint) : ";
	cin>>a;

	cout<<"Please enter number of cartoons(1-20) : ";
	cin>>b;
}

Notice the ampersands (highlighted in red), to denote 'pass by reference' ... also, the function has no retun statement, since it is modifying variables elsewhere in the prgram and not returning a value, hence the function's return type is now void

Bench 212 Posting Pro

I think what you may be looking for is more general computer science theory than anything specific to C++ (especially if you have no interest in learning the language at this time). You should google around for OO design theory, since it applies to many other languages, not just C++ (in fact, if you are looking to learn a language purely for its OO features, you could choose to learn Smalltalk or Python instead).

Polymorphism in C++ might sound a little odd to you. it doesn't work on objects as such, but with pointers-to-objects (and if you don't know what a pointer is, then this explanation maybe won't be much help to you)

When a pointer is created, it's given a "pointed to" type. eg, for a non-polymorphic example, if a pointer has an int as its "pointed to" type, then you may point it to any object within your program which is of the type int.

If, on the other hand, the"pointed to" type is a class, then it may point to any object within your program which is of that class.
here's where polymorphism can happen, because the pointer may also point to objects derived from that class.

Let me reiterate - OO Polymorphism in C++ is not about changing objects, it's about changing pointers. You cannot change the data type of variables within an object. and you cannot even change an object from one derived type to another (Not safely anyway.. it's …

Bench 212 Posting Pro

[De-cloak] :eek:

Assuming that your array of random numbers is constant, then your 4 elements are always indexed by the numbers 0,1,2,3 .... that should make life pretty simple :) Start it out as a simple random-number picker for the numbers 0-3 and carry on from there.

[/De-cloak]

Bench 212 Posting Pro

The majority of ads on here are google ads, which are relatively non-intrusive IMHO, compared to some sites which use horrible flash-based ads (I deliberately have a flash blocker for those, since uninstalling flash just meant i was prompted to reinstall flash every 5 minutes :mad: ). If you use Firefox, you'll notice that it has the built-in ability to block graphics from any sites you choose :)

Bench 212 Posting Pro

So I try "\-126" and get a compile error. Any other ideas?

"\-126" isn't a char, the double quotes translate that you are attempting to use a string literal, which isn't what you want. There should be no need for the backslash either, since you're not using an escape character.

Just to re-iterate, this is not a C++ issue, this is an implementation-specific font issue. The windows 2000 cmd.exe console uses the "Terminal" font, hence why I got a value of -126 (or 0x82) for the 'é' character. if your implementation uses a different font, there's a strong possibility that the number -126 is not what you need (The code in my earlier post is indifferent to the font)

rambling aside - here is how you might print the é character, if your output uses the Terminal font.

#include <iostream>

int main()
{
    char c = -126;
         // you could also use 0x82 instead of -126
    std::cout << c;
}

or..

#include <iostream>

int main()
{
    std::cout << static_cast<char> (-126);
}

You may also be able to change your IDE to use the same font as your console window, although I haven't tested that idea.

Bench 212 Posting Pro

I need to insert a "é" and other such symbols. At first I just tried using é straight out in C++ and it returned Θ. So I looked at my character map and did the unicode version \u00E9 where I wanted the é and it still returned Θ. I guess they are using two different standards. Can anyone point me to a list of such common special characters and their c++ encodings? My attempts at a google search have been inconclusive. Thanks :cheesy:

There's nothing standard about extended ASCII characters. the extended ASCII code for that character in your IDE's font is obviously different to the code in your output console's font.

using this code, the character é yields a value of -126 on my system

#include <iostream>

int main()
{
    char c;
    std::cin.get(c);
    std::cout << static_cast<int> c;
}
Bench 212 Posting Pro

You're trying to create objects of type Button, but don't have the constructors to match. Remember that if you provide your own constructor within a class, then you do not get a default constructor.

You also seem to have other problems - you can't assign an int to an object of an enumerated type. eg,

stats = Status(1);

this needs to be

stats = idle;
Bench 212 Posting Pro

I know there is a book section, but I'm accually more after personal suggestions/reviews.

Did you actually read the C++ Books thread stickied at the top?

Bench 212 Posting Pro

And now.. fun with names and pointers ;)

#include <iostream>

template<typename T, int i>
int J(T (&arr)[i]) { return i; }

class C{};

int main()
{
    C plus_plus[10];
    C* c(plus_plus);
    do
    {
        c++;
        std::cout << c-plus_plus << '\n';
    }while( (c-plus_plus) != J(plus_plus));
}

:D


!multiple edits! - had to change the code since it wasn't pasting properly :confused:

Bench 212 Posting Pro

in a somewhat similar vein to using binary operators - here's one using base-2 logarithms in C++ :)

#include <iostream>
#include <cmath>

int main()
{
    for(int x(1<<1); x<=1<<10; x=x<<1)
        std::cout << (std::log(static_cast<double>(x)) 
                      / std::log(2.0)) << "\n";
}
Bench 212 Posting Pro

This was my usenet signature for a long time :)

"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989

Bench 212 Posting Pro

Using binary arithmetic operators in C++ :)

#include <iostream>

int main()
{
    int a(0);
    while(a!=10)
    {
        int r,c, b(1);
        do
        {
            r=a^b;
            c=(a&b)<<1;
        } while( (a=c) && (b=r) );
        std::cout << (a=(r?r:c)) << '\n';
    }
}
Bench 212 Posting Pro

Yup, That looks much better :)

Bench 212 Posting Pro

Hello, This is mainly a message to Dani (although interested to know whether anyone else has seen this..)

The the PM message frame extends too far to the right (at least on my screen @ res 1280x1024). It cuts off the right-hand-side of the PM message window, so long lines like this end up obscured underneath the site navigation & google ads.

This happens both in Firefox (latest ver: 1.5.0.3) and MSIE 6

Sorry if someone has already pointed this out, I couldn't find anything in the feedback forum :)

This image shows what i mean, although it happens when viewing PMs aswell as composing them.

Oversized screen dump ;)

Bench 212 Posting Pro

You have included the C++ string library in your code, so why don't you actually use it? C-Style strings (char[] and/or char* ) are considered 'bad' in C++ - They are just making your life harder, and your code less readable.

also, this line is bad (even in C, I believe this is a bad idea)

fflush(stdin);

instead, use std::cin.ignore(); to ignore the next character (probably just a newline char), or std::cin.ignore(INT_MAX, '\n'); to ignore all characters up to a newline.

I'm not totally clear what you want you mean by "output the puzzle again" output the puzzle after what?

Use std::toupper() from the <cctype> library to put a single character in uppercase.

To perform toupper on a string, you can either loop through each element of the string, or you can use the STL algorithm std::transform() another issue making your code less readable - you've got alot of repeated code in your solvepuzzle() function - maybe you could break that down into smaller sub-functions.