Bench 212 Posting Pro

I assume you've been given all this code by your tutor..? Where is the implementation code for each of the member functions? (It looks like you've been told to write that)


You will need to call a member function which accepts a char* (You have got one of those.. )

Bench 212 Posting Pro
int main()
{
	string nameStr  = ""; //Not necessary to initialize
	string topicStr = ""; 
	string t2 = "mom";
	string t3 = "sex";
	string t4 = "* *";
	string t5 = "*";
	string t6 = "**";
	string t7 = "***";
	string t8 = "****";
	string t9 = "*****";
	string t10 = "******";

I would suggest learning about arrays and STL containers in order to hold data, rather than creating a long list of variables holding all the words you want the program to remember. (With an STL container, such as a Vector or List you can dynamically add words to your collection as the program runs )

eg, this program retrieves a few lines of text from the user, stores them in a vector of strings, called my_dictionary, and outputs the stored text again at the end.

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    vector<string> my_dictionary;
    string a_word;

    const int num = 4;

    for( int i = 0; i < num; ++i )
    {
        getline( cin, a_word );
        my_dictionary.push_back( a_word );
    }

    for( int i = 0; i < num; ++i )
        cout << my_dictionary.at( i ) << ' ' ;
}

As for getting the computer to derive responses from your conversation, you can make that as simple or as complicated as you like... how you do it is up to you. One simple way to do it might be to create an STL <map> of words, along with their responses, …

Bench 212 Posting Pro

Can you do this without any problem?

int value = 'A';
printf( "%c", value );

I was told that mixing types is bad.

there's nothing wrong with mixing char and int per se, although whether or not its 'bad' depends entirely on context.

an int must always be at least as large as a char, just as a general rule. Both int and char are integral types, although, the default representation of a char (when output as text) is as a character rather than a number.

It becomes "bad" in situations where you might attempt to fit a value into a variable when the variable isn't big enough to hold it.

Bench 212 Posting Pro

If the solution fits the requirements as laid out in the requirements document the customer signed off on as part of their contract, then yes he has to pay for it.

I'd (if I found out that the actual technical needs are different from what the customer stated) notify the customer that the requirements (and thus the contract) had better be ammended (possibly introducing extra cost for the customer, depending on the extra effort or investment needed on our part) or the software wouldn't meet his needs (rather than his stated requirements), but I would need to have some idea of the actual use he was going to make of the stuff beforehand.

This is why project managers and systems analysts exist - its their job to understand the requirements of the client before anything gets set in stone.
Chances are that the client isn't entirely aware of all the details of their problem(s) which need solving, so these people also have the job of explaining to the clients what the problem is, and, if done responsibly, the end result should be that the client will sign off on a document that fits their problem

Or, maybe in reality, a document outlining something else, which they've been talked into believing fits their problem, until a later date when the reality hits them that they've signed up for something they didn't want.

Bench 212 Posting Pro
//source error
long long byParam[2] = "";

Try this instead, to initialise all elements to zero

long long byParam[2] = { 0 } ;
Bench 212 Posting Pro

Polymorphism occurs because of dynamic binding, which is made possible through use of pointers (The compiler internally represents a virtual function as a pointer, whose value is determined at run time) -

however, a static function is just that - its not a function pointer, but an object which has a static address.

If you want to call a derived class static function through a base class pointer, then you can use a non-static virtual function wrapper to achieve the same thing. eg,

#include <iostream>

class Base
{
    static void foo() { std::cout << "Base\n"; }
public:
    virtual void bar() { foo(); }

};

class Derived : public Base
{
    static void foo() { std::cout << "Derived\n"; }
public:
    virtual void bar() { foo(); }
};

int main()
{
    Base* obj = new Derived;
    obj->bar();
    delete obj;
}
Bench 212 Posting Pro

>But you would have to accept a solution using the standard library
>given your stated requirements since they lack mention of
Nope. The point of many of these questions is to figure out exactly what the requirements are before trying to come up with a solution. Vague requirements are very common with clients, and you're basically saying that I (as the client) have to accept your solution as final even if it's your fault that the solution is worthless. How many clients do you think would pay if you tried to pull that?

Indeed - if this thread has taught me one thing, its to question every word of every sentence, and to question every assumption that results .. I guess the old adage reigns true - You only truly understand the problem around the time you've finished creating the solution :)

Bench 212 Posting Pro

Maybe you could add it to your INCLUDE environment variables in Windows
(Note: exact sequence here may be different on WinXP/Vista ... i'm using Win2K)

  • Right-click on My Computer and choose Properties
  • Go to the Advanced tab, and press the button for Environment Variables.
  • Scroll down the list of system variables, and look for the one called INCLUDE

the variable will look something like this...

d:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\

add a semicolon to the end, and then add C:\Program Files\MySQL\include\

so it'll look more like..

d:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\ [B]; C:\Program Files\MySQL\include\ [/B]

You might need to restart for it to take effect... but after that, try compiling it again :)

Bench 212 Posting Pro

>Based on that, here's my third attempt
Close, but you're still treating the arguments as one whole string. You only get them one at a time. For example:

#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main()
{
  typedef string Token;
  
  istringstream tokenizer ( "arg1 arg2 arg3" );
  Token tok;

  while ( tokenizer>> tok ) {
    // TODO: Add the token to the stack frame
  }
}

You're welcome to modify the loop, but the tokenizer is an integral piece of the compiler, so we can't rewrite it to give you all of the arguments as a single string.

Ah, I guess i missed the clue you put inside that loop before - As i think about it, i've been over-complicating it a little.
I decided to approach it, assuming that I knew absolutely nothing about the type of Token ...

template<typename TokenType>
class tokenstream
{
    struct holder_t
    {
        TokenType token;
        holder_t* next;
        holder_t(TokenType t, holder_t* h) : token(t), next(h) {}
    } * head;
public:
    tokenstream() : head(NULL) {}
    ~tokenstream()
    {
        while(head)
        {
            holder_t* temp(head);
            head = head->next;
            delete temp;
        }
    }
    bool add(TokenType);
    TokenType next();
    bool is_empty() { return ( head == NULL ); }
};

template<typename TokenType>
bool tokenstream<TokenType>::add(TokenType t)
{
    head = new holder_t(t, head) ;
    return( head != NULL );
}

template<typename TokenType>
TokenType tokenstream<TokenType>::next()
{
    if( head == NULL )
        throw("tokenstream: token list empty");
    TokenType t( head->token );
    holder_t* temp( head );
    head = head->next;
    delete temp;
    return t;
}

So, …

Bench 212 Posting Pro
iamthwee commented: Too right! +12
Bench 212 Posting Pro

ah ok.. Based on that, here's my third attempt :icon_smile:

#include <iostream>
#include <string>

class tokenstream
{
public:
    typedef std::string token_type;

    tokenstream(const char args_in[], char delim) : delimiter(delim), 
        tokens(args_in), fail(false) {}

    tokenstream& operator >> (token_type&);
    operator bool () const { return !fail; }
    operator = ( token_type );
    operator = ( const char* );
    void clear() { fail = false; }
private:
    bool fail;
    token_type tokens;
    const char delimiter;
};

tokenstream& tokenstream::operator >> (token_type& tok_out)
{
    if( tokens.empty() )
    {
        fail = true;
        return *this;
    }

    size_t pos = tokens.rfind(delimiter);
    if( pos != token_type::npos )
        tok_out = tokens.substr(pos+1);
    else
    {
        pos = 0;
        tok_out = tokens.substr(pos);
    }
    
    tokens.erase(pos);
    return *this;
}
   
tokenstream::operator = ( token_type str )
{
    tokens = str;
    return *this;
}

tokenstream::operator = ( const char* str )
{
    tokens = str;
    return *this;
}

int main()
{
    const char* arg_list("arg1 argument2 very_long_argument_number_3 argument_4");
    tokenstream tokenizer(arg_list, ' ');
    tokenstream::token_type tok;
    while( tokenizer >> tok )
        std::cout << tok << ' ';
    std::cout << "\n\n";

    tokenizer.clear();

    char more_args[]("sheep cow horse chicken");
    tokenizer = more_args;
    while( tokenizer >> tok )
        std::cout << tok << ' ';
    std::cout << "\n\n";
}

I can see that I should have asked more questions about how the code was going to be used.. :icon_smile:

Bench 212 Posting Pro

We'll be using the parameter identifiers themselves as keys into a map for the symbol table, so it's probably not a good idea to modify the source strings. So in our case, the list [arg1, arg2, arg3] would be reversed into [arg3, arg2, arg1] .

In which case, i'll make the assumption that the input is going to look like [arg1, arg2, arg3] - and that this input needs to stay as-is.

I forgot to tell you that our development environment is extremely buggy and resource intensive (management is looking into replacing it). Using the standard library would be a bad idea for this component since it'll be used very often during a compilation phase.

Wouldn't it be better, then, to write it as a 'C' program? :)

Assuming, at the least, the C standard library is available (By my reckoning, any function from the C standard library is probably going to be at least as efficient for a task as any other)

#ifndef ID_LIST_H
#define ID_LIST_H

#include <cstring>

class identifier_list
{
    char* params;
    const size_t size;
    const char delimiter;
    static char* strip_symbols(char* const);
    static char* validate_tokens(char* const);
    static char* reverse_order(char* const, size_t, char);
public:
    identifier_list(const char args_in[], char delim) : delimiter(delim), size( strlen(args_in) + 1 )
    {
        params = new char[size];
        strcpy(params, args_in);

        params = strip_symbols(params);
        if ( !( params = validate_tokens(params) ) )
            throw("Invalid Identifier List\n");
        params = reverse_order(params, size, delim);
    }

    const char* get();     

    ~identifier_list()
    {
        delete[] params;
    }
};

#endif
#include <cstring> …
Bench 212 Posting Pro

Problem: Write some code that reverses words.

My first thought which springs to mind, is, how would you define a 'word'?

is it..

  • A sequence of alphanumeric characters
  • A sequence of alphanumeric characters & punctuation
  • A sequence of purely Alphabetical characters
  • Assuming any particular character set (ASCII, Unicode, etc)

My next thought... what do you mean by "reverses words"

  • Reverses the order of a list of "words" (assuming "word" is defined)
  • Reversing the order a set of characters appear in a word
  • A combination of the above (Which would be more like reversing a 'sentence')

Those questions aside, here's how i'd do it in C++ (Making assumptions about the above, of course :) )

#include <iostream>
#include <ostream>
#include <string>
#include <sstream>
#include <deque>
#include <algorithm>
#include <functional>

class reverse_word : public std::unary_function<std::string, std::string>
{
public:
    std::string& operator()(std::string& str)
    {
        std::reverse(str.begin(), str.end());
        return str;
    }
};

int main()
{
    std::string str ("the quick brown fox jumps over the lazy dog");
    std::cout << str << std::endl;

    std::stringstream ss (str);
    typedef std::deque<std::string> list_t;
    list_t word_list;
    std::string temp;
    while( ss >> temp )
        word_list.push_back(temp);
    std::for_each(word_list.begin(), word_list.end(), reverse_word() );
    list_t::const_iterator i;
    for( i = word_list.begin() ; i != word_list.end() ; ++i )
        std::cout << *i << " ";
}
Bench 212 Posting Pro

That kind of error usually means you've missed out a definition somewhere - For example, if you've declared something in a header file, such as a function. Elsewhere in your code, you may have called that function, and the linker is unable to find the implementation to go with it.

Without seeing the code which exhibits the problem, there's no way to give any more information than that.

Bench 212 Posting Pro

also, if b had data in it previously, does this cause a memory leak due to abandonment of the heap area formally pointed to by b? Will the statement delete [] b; recover it even after direct re-assignment?

In the example you gave, you haven't used new[], therefore you shouldn't use delete[]

Perhaps you intended lines 1 and 2 to look more like this?

char* a = new char[11];
char* b = new char[11];

in which case, the use of delete[] would be correct.

In general, when you allocate memory with new, deallocate it with delete.
when you allocate memory with new[], deallocate it with delete[].

Bench 212 Posting Pro

For Q1:
I can understand the use of private -> to inherit dummy members privately.
But what role does "virtual" playing here. As far as I know virtual keyword is required to avoid the problems like Deadly diamond of death so that only one copy of base class get inherits. In this case we dont have condition like that then why virtual. If I remove virtual from here my motive wont fullfill :(

Can anyone throw some light on it ?

Many Thanks to all.

Simply put, the role of virtual means that any derived class constructor needs to call the virtual base class's constructor. - However, the base class is inherited privately, so all members of the virtual base, including the constructor, are hidden from the derived class. This means its impossible to create an instance of any derived class.

Bench 212 Posting Pro

Their use and meaning depends entirely on context. For built-in integral types, they are bitwise operators for bit-shifting operations. Under these circumstances, << means "shift left" and >> means "shift right".

More commonly, you see them in C++ for input and output. Under these circumstances, << means "Outputs to" and >> means "Gets input from"

the two most common examples -

#include <iostream>

int main()
{
    int i;
    std::cout << "Enter a number: ";
    std::cin >> i;
}

Line 6 of the code could be translated to read

"Enter a number: " Outputs to std::cout

Line 7 of the code could be translated to read

variable 'i' Gets input from std::cin

In both cases, the statements are read right-to-left in the code snippet.

Bench 212 Posting Pro

Sorry I interprete wrong :
what i understand that if i run the bat file then system gets shut down,
but it is just keep running the command prompt. shwing the command which i saved i.e. shutdown -r -f -m \\IP -t 60

And what happens when you just type it in directly to the system's console?

FWIW, if the command you've got doesn't work when typed in directly, or run from a batch file, then wrapping it in C++ code isn't going to do any different.

You should visit a forum specific to the OS on which you're attempting to run the command - they might be better able to help you with the problem

Bench 212 Posting Pro

A couple of ways - which are explained by this link far better than I could.

http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.11

Bench 212 Posting Pro

AHA!
So that probably explains why this works, even though "per" was declared as a character array:

cout<<per<<endl;

Am I on the right track?
Do have good URL for further reading?

The reason it works is because operator<<() is overloaded for all the built-in types to work with std::ostream - including char*. Although as Lerner explained, a character array with no '\0' terminating character doesn't constitute a string, and shouldn't be expected to work the same way.

With operator overloading, its also possible to extend the functionality further with your own types - Have a look here for a little more on operator overloading
http://www.parashift.com/c++-faq-lite/operator-overloading.html

Bench 212 Posting Pro

Dragon , thanks for your reply but the program doesn't contain any definition for operator = function

I believe Ancient_Dragon is aware that you haven't explicitly defined operator=() in your class, which is why he mentioned it.

Look at the line in your code which he pointed out - you are calling operator=() but have no definition for it - therefore your class is using its default operator=()

The method of initialisation which occurs when using operator=() is not the same as when using explicit object construction - a temporary copy of the object is created first before your object is initialised by way of the assignment operator.

Bench 212 Posting Pro

it looks OK so far - Although I would suggest seperating your file input function out away from your book class, unless you want every single book object to hold exactly the same information (When you close a file and re-open it, the file reads from the start of the file again)

If you're satisfied with the book class at the moment, then your next step is probably to write your Fiction and Nonfiction classes

Bench 212 Posting Pro

If you'd like to have a look at the code for one particular implementation of the STL, then check the SGI website for their source code

http://www.sgi.com/tech/stl/download.html

Bench 212 Posting Pro
...
while(std::getline(file,temp))
    str += temp;

Of the 3 solutions you posted, this is the only one which won't crash and burn once the file hits EOF. the EOF flag is not set until after the stream reaches EOF (A read is attempted and fails) - which means your final call to getline will break, causing problems for the final iteration of the loop.

The loop in this example doesn't rely on EOF, so it works well.

As a general rule of thumb, you should never use EOF as a loop's terminating condition when reading from a file.

Bench 212 Posting Pro

So you are telling that arguing about whether to use dev c++ or VC++ has got everything to do with the topic WHAT ARE VECTORS?

If they are to you then I think you don't understand English.

Did you read the replies you got at the beginning of the thread? Your question was answered there - If you need a more detailed explanation than the one you recieved, then you need to ask a more specific question

The compiler discussion has been brought about by the fact that your ancient old Turbo C++ compiler doesn't support many modern C++ language features, vectors likely being one of these features.

Bench 212 Posting Pro

Hi to all
I have a quick question. I am going to fill an array with some inpuit of type char using member function cin.getline. After I fill an array ,I would like to do "for" loop so I need to know what is curently the size of an array. Is it possible. Looks like stupid question because I initialized the array that contains 250 elements (and what I know so far I can't chang ethe size of array, isn't right?). But if I would enter let sey 25 characters. Is the size going to change?Is it possible. If so how may I got the current size of the array. If not what is the best choice to fill an array (maybe vector ?) ,tht will let me know the current size of array
Thank you

The best choice would be a std::string - which is a container specifically designed for holding characters (Far more appropriate to the task than a vector). You can use a std::string with getline() too - eg,

#include <iostream>
#include <string>

int main()
{
    std::string str;
    std::getline(std::cin, str);
    std::cout << str << " length: " << str.length();
}
Bench 212 Posting Pro

Check out Bruce Eckel's Thinking in C++, 2nd Edition (Vol.1), available as a free e-book from his website

http://mindview.net/Books

Bench 212 Posting Pro

These aren't examples of quines though - To qualify as a quine, the program must be able to replicate its own source code without any input (either from a file, the keyboard, or anywhere else)

see here for a little more info http://en.wikipedia.org/wiki/Quine_%28computing%29

Bench 212 Posting Pro

Hi Guys,

I'm having the folowing problem related to the system function.
I want to be able to read from a txt file a string

This part doesn't have anything to do with the system() function - you should look up the <fstream> library for file I/O

and then launch the string as a bat file. For example, the text file contains "HP DC 7700" and i want to run the bat "HP DC 7700.bat".
I have no ideea on how to pass what I read from the txt to the system function....
Can you help me out?

Thanks and cheers!

Once you've obtained the string which you wish to execute, you can pass it as a parameter to the system function.

with a C++ string, it would look something like this -

#include <string>

/* ... */

    std::string my_string("HP DC 7700.bat");
    system( my_string.c_str() );

/* ... */

the system() function requires a const char* between its parenthesis, which is provided by the c_str() member function.

Bench 212 Posting Pro

@ narue unless of course someone else knows exactly what she means.

I expect the reason is that C is still the most widely used general purpose programming language. It doesn't really matter what features are available in C++/Java/etc when an existing system is written in C - many jobs will likely involve maintaining or updating legacy code rather than starting out entirely from scratch - something which you can't do unless you're familiar with the language its written in.

Bench 212 Posting Pro

Syntax changes from your snippet are highlighted in bold red

#include [B]<iostream>[/B]
[B]int[/B] main()
{
   int n,x,y;
[B]std::[/B]cout<<"n=";
for (x=1; x<=n; x++)
{
   for (y=3; y<=8; y++)
   [B]std::[/B]cout<<y;
 }
   return 0;
}

Note that your code still does not specify a value for 'n' anywhere (Perhaps you intended to retrieve it from the user?)

Just to re-iterate what I said in my last post - If you're using an old, pre-standard, compiler, then this won't compile - and you'd be well advised to download a modern compiler.

Bench 212 Posting Pro

Here's another article which may make interesting reading - Further detail on the Right-Left rule
http://www.codeproject.com/cpp/complex_declarations.asp

Bench 212 Posting Pro

I don't know WHY you need to do thsi, so it's hard to guess what other methods might be appropriate.

For a statically allocated array, the size must be known at compile time - therefore there's no reason to allow a non-const variable to be used to declare an array.

Allowing such behaviour inevitably invites beginners to try such things as the following, which, if it weren't illegal, would be undefined behaviour

int main()
{
    int size(5);
    int arr[size] = { 1,2,3,4,5 };
    size = 8;
    arr[5] = 6;
}

Disallowing non-const variables to be used in static array declarations adds a compile-time check to help prevent this kind of code appearing.

There may be other reasons the ISO standards committee decided to disallow it, but this seems reason enough to me.

Bench 212 Posting Pro
#include<iostream.h>
main()
{
   int n,x,y;
cout<<"n=";
for (x=1; x<=n; x++)
{
   for (y=3; y<=8; y++)
   cout<<y;
 }
   return 0;
}

***************
and this was supposed to be the output for that problem..
345678345678345678
i don't know if my code was correct..so pls do help me because i really want to learn..

Unless you're using a very old (pre-standard) version of MSVC++, then no, it's incorrect (Certainly doesn't compile on any of the recent versions)

On modern compilers, the correct header is <iostream> (without the .h) - and you need to obtain cout from the std namespace


Regardless of the compiler version, in your for loop, You use the variable 'n' without previously defining what 'n' is, and you're missing a return type from main() ( main() should return an int )

For starters reader this and if you still want to use c this

I hate quoting narue's snippets, I feel so dirty. :(

Any particular reason for this? both articles seem perfectly good to me.

Bench 212 Posting Pro

Nothing serious, just a couple of nitpicks -

#include <iostream>
#include <math.h>

Since this is C++, change that to #include <cmath>

unsigned long extract_digits ( unsigned long x, size_t n, size_t i )
{

        int z=0, c=x;

'x' is an unsigned long - don't take the risk that int and unsigned long are a different size, keep 'c' as an unsigned long too.

Bench 212 Posting Pro

the Cable Disconnected message when the device at the other end of the cable is switched off is perfectly normal.

What are the IP addresses of each workstation? are you able to "ping" each machine from the other in the command prompt console window?

Do you have NetBIOS enabled on each workstation in the advanced TCP/IP properties for the Local Connections? (Might be disabled by default, if so, enable it)

Do you have the File & Print Sharing service installed? (Should be installed & available by default)

Bench 212 Posting Pro

Nothing wrong as far as I can see - as long as you #include <iostream> and have a std namespace declaration.

Did it not compile for you? What compiler are you using?

Bench 212 Posting Pro
for (int i = 1; i <= 3; i++)
  {
  InputName( name,  mark);
  symbol( sym, mark);
  displayMessage(sym, name);
 
 
  }

You've called your symbol function, but you haven't done anything with the returned value.

If you don't wish to use the return value, then you will need to pass sym by reference, ie

char symbol(char & symbolP, int markP)
Bench 212 Posting Pro

So its
(***FuncName)()

Its legal because functions have no values so the dereferencing asterik has no effect on the function name?

Pretty much, yes.


although it would be noteworthy to say that code like this doesn't pass QA when it comes to readability.

void foo()
{
}

int main()
{
    (****foo)();
}

Make sure that when you use the dereference operator, that it actually enhances the readability/meaning of the code, and doesn't detract from it.

Bench 212 Posting Pro

You're getting confused between two very distinct topics in C/C++ - Pointers, and function pointers, which are both a rather different kettle of fish.

The reason that function pointers can be handled in such a way as shown in your original post is because of the nature of functions themselves.
in C/C++, you can really only do two things with a function - you may call it, or you may take its address.

Contrast this with a variable, you may also take its address, but you may not call it. In addition to this, unlike functions, you can assign to it, and you can obtain the data it stores.

Since functions and variables are so different, it follows that a pointer-to-function behaves differently to a pointer-to-variable.


Just to put the above into context, when you use the name (identifier) of a function, without the trailing parentheses, the compiler already knows that the function cannot have a value stored, therefore the address of the function is returned instead - the & (address-of) operator is unnecessary.

When you use the name/identifier of a variable, the compiler assumes you wish to obtain its stored value. Hence, if you wish to obtain the address of a variable you must explicitly use the '&' (address-of) operator.


The example you posted using the * (dereference) operator is not legal for the same reasons listed above. this is - a function has no stored data value, …

Salem commented: Nicely put +7
~s.o.s~ commented: Good one. +19
Bench 212 Posting Pro

normally runs at 49333 to 51000 bps (THIS I AM CRYING ABOUT).

Don't expect to get any faster than this on ordinary dialup - it won't happen. In fact, that's pretty good for a 56k modem - My old dialup connection (in the UK on a good telecoms infrastructure) used to connect at 44000 bps most days.

Bench 212 Posting Pro

Aside from file/printer sharing, does the network work OK?

Windows File & Print sharing is usually dependent on NetBIOS - make sure that you have enabled NetBIOS over TCP/IP on both workstations.

You will find the option to enable NetBIOS in the advanced TCP/IP settings for your network interface

Bench 212 Posting Pro

Its a way of starting an infinite loop which will be stopped using some means other than the condition inside the brackets next to while.

eg,

void somefunc()
{
    std::string str;
    while(true)
    {
        std::getline(cin, str);
        if( str == "quit" )
            return;
        else
            std::cout << "You Typed: " << str << std::endl;
    }
}

IMHO, this kind of idiom is seldom useful - unless you have some compelling reason to do otherwise, you should put an exit condition in the while brackets

Bench 212 Posting Pro
Bench 212 Posting Pro
openInFile( ifstream & inp , string iNam ) ;
    readData( ifstream & inp , int ary[] , int SIZE ) ;

What are you trying to do here? call the openInFile and readData functions? don't include data types when passing function parameters

openInFile( inp , iNam ) ;
    readData( inp , ary[] , SIZE ) ;

Also make sure you've got a forward declaration for your openInFile function

Bench 212 Posting Pro

Do both ethernet ports work individually when plugged into the router (or some other network device) ?

What TCP/IP Settings do you use for the ethernet adapters on each computer? (if any, or Automatically detect settings?)

Are both ethernet adapters set to autonegotiation for speed and duplex settings?

Bench 212 Posting Pro

Is it that time of year when students have 6-month-long projects to start with 3 days remaining? :P

Bench 212 Posting Pro

The '\0' character marks the end of a 'C'-Style string. in C++, there is the <string> library which lets you avoid the use of raw character arrays. (the C++ std::string type is not too dissimilar to Java's String type).

Regardless of whether you are using C or C++, moving the '\0' character around isn't the solution. (both languages have library functions for string manipulation)

in the <cctype> header, there is a function called isspace(), which returns non-zero (true) if a character is whitespace - i.e. newline, carriage return, tab, or space.

Think how you would find the first and last occurrances of non-space characters, and save their positions. Once you have these positions, think about how you would calculate the length of the remaining string.

Once you know the starting position of the remaining string, and its length, use the string::substr() method/function
If you are going to carry on using 'C' style strings, then lookup the strncpy() function.

Bench 212 Posting Pro

Take advantage of the fact that characters are represented by integer values on your computer, and therefore may be added to other integer types.

char convert(int i)
{
    return (i%26) + 'A';
}

EDIT: Note - This depends on the character set on your computer having the letters 'A'..'Z' as a contiguous set. As far as I am aware, most character sets do (such as ASCII), but there is always a possibility that some obscure character set somewhere in the world doesn't.


EDIT2: For the more portable solution using the <string> library

char convert(int i)
{
    std::string s("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    return s.at( i % s.size() );
}
Bench 212 Posting Pro

There's no difference. manually check to make sure the file exists at the location from which you are trying to open it. Then check the file in notepad to make sure its contents are what you are expecting to read