Duoas 1,025 Postaholic Featured Poster

You have three cs there:
line 51
line 55
line 59
Your loop will never terminate because every c is always == first (so no matter which of the three the compiler chooses to use you've got an infinite loop).

Make sure to use just one c.

Also, watch how many times you change first. You want to bump it just once (if I understand you right).

void print() {
    listitem *c=first;

    if (c) {
        printf("%d\n", *c);
        c=first=first->next;

        do{
            printf("%d\n", *c);
            c=c->next;
        }while (c != first);
    }
  }

Hope this helps.

[edit] BTW. What if your circular list has just one item? (It will get printed twice.)

Duoas 1,025 Postaholic Featured Poster

Now you have confused me.

You don't need to allocate the size of a std::string --that's the whole point. But you do need to specify the size of a c-style character array.

Both my methods are correct.
Both use cin.

Never use gets(). (It is pure evil, and should be shot.)

If you want to use the old stdio functions to input c-strings, use fgets()

#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
  {
  char name[ 100 ];  // this is an array of characters
  char *p;
  cout.sync_with_stdio();
  cout << "Please enter your name> ";
  fgets( name, 100, stdin );
  if (p = strchr( name, '\n' )) *p = '\0';
  cout << "Hello " << name << "!\n";
  return 0;
  }

Notice how on line 12 I had to manually remove the newline (from the ENTER key) from the input string.

[edit]
Neither incarnation of getline() stops at the first whitespace unless you tell it to. They stop at the end of the line.
However, cin >> foo; does stop at the first whitespace.

Duoas 1,025 Postaholic Featured Poster

Don't test against true. Test against false.

That is the danger in defining values for true and false. Just remember, always (and this is one of 'those' rules...) explicitly test against false. Only implicitly test for true:

if (x != false) yah();
if (x) yah();

if (x == false) fooey();
if (!x) fooey();

If your compiler still complains, just do an explicit cast:

if ((bool)(x || y)) yah();

Good luck!

Duoas 1,025 Postaholic Featured Poster

You are confounding c-style strings and stl strings.
An old c-style string:

#include <cstring>
#include <iostream>
using namespace std;
int main()
  {
  char name[ 100 ];  // this is an array of characters
  cout << "Please enter your name> ";
  cin.getline( name, 100 );
  cout << "Hello " << name << "!\n";
  return 0;
  }

An STL string:

#include <iostream>
#include <string>
using namespace std;
int main()
  {
  string name;  // this is a string object. It has no maximum size
  cout << "Please enter your name> ";
  getline( cin, name );
  cout << "Hello " << name << "!\n";
  return 0;
  }

When you say string foo[ 10 ]; you are saying that 'foo' is an array of ten string objects... probably not what you meant.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Windows can do that for you with the LoadImage() function, and that returns a windows HANDLE to the image resource, which you must select into a compatible DC to display or access its pixel data (as usual).

If you want to access the image differently (for example, if you have your own image display routines, etc.) you'll have to do as iamthwee suggests.

Good luck!

Duoas 1,025 Postaholic Featured Poster
#include <iomanip>
#include <iostream>
using namespace std;

int main()
  {
  for (int n = 1; n < 6; n++)
    cout << n;
  cout << setw( 5 ) << right << (167) << "mm\n";
  return 0;
  }

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

What OS are you using?
If you are using a GUI, what GUI toolkit are you using?

If you are on Win32 console, you should check out Microsoft's Console Function reference.
Here is an example.

If you are on Linux console, you should check out NCurses, which can do mouse interfacing.

If you are using a GUI, look in your toolkit's documentation.

Good luck!

Duoas 1,025 Postaholic Featured Poster

The main problem is that iostreams cannot be copied. Consider for a moment the horrors that can occur if you have three copies of an object that manipulates a file sitting around.

You must pass them by [i]reference[/i].

So, if you want your class to have a fstream, you should either make the class uncopyable or give it a reference-counted pointer to a dynamically-allocated fstream.

The [URL="http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/smart_ptr.htm"]Boost Library's Smart Pointer[/URL] classes may be of use to you. In particular, use
[URL="http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/shared_ptr.htm"]shared_ptr[/URL]<fstream> fichier;
in your class. When you initialize the class, or open the file (whichever), construct yourself a new fstream
[inlinecode]fichier = new fstream( "essai.txt" );[/inlinecode]
Thereafter, you can copy your class and each [i]copy[/i] will have a pointer to the [i]same[/i] fstream, and you won't have to worry about [b]delete[/b]ing it at the appropriate time. And, of course, distinct instances of your class (not copies) access different files.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

There is nothing more or less hard about C++ than any other programming language.

People fear C++ because it comes with a very large set of capabilities.

It can be used to program procedurally.
It can be used to program object-orientedly.
It can be used to program generically.
It can be used to program functionally.
It can be used for very low-level machine programming.
It can be used for very high-level abstract programming.
It can do all of the above at once.

It comes with a very large standard template library --which takes some time to get used to.
And it mixes very well with C, which is often a source of confusion for new programmers.

The core language is not large. But the vast capabilities of the language and the size of the STL can sometimes make it seem like a hulking beast.

You can read Bjarne Stroustrup's FAQs about the language at his site
http://www.research.att.com/~bs/bs_faq.html
You might want to give particular attention to the second section, but the entire document gives a lot of useful information.

Hope this helps.

Ancient Dragon commented: Excellent description :) +34
Duoas 1,025 Postaholic Featured Poster

No, it won't compile with VC++. The above code is for Borland C++.

The important part is sending and receiving messages from the rich edit control with SendMessage().

Duoas 1,025 Postaholic Featured Poster

If you are stuck with ancient 16-bit tools, look in the documentation for "overlays".

However, I wholly endorse Salem's recommendation to git yerself a mo-dern compost piler.

Duoas 1,025 Postaholic Featured Poster

Use sprintf() or a std::ostringstream to convert the date to a string, then use outtextxy() to print the string.

char buf[ 20 ];
sprintf( buf, "%d/", d.da_day );
outtextxy( 200, 100, buf );
// I'm pretty sure that Turbo C++ uses a different header name
// for the stringstream... it might be <stringstream>
#include <sstream>
...

ostringstream ss;
ss << d.da_day << "/";
outtextxy( 200, 100, ss.str().c_str() );

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Argh... sometimes I'm dismayed that Borland's C++ version of a control is wimpier than the Delphi version.

[edit]
I just re-read your post and realized that you said Visual C++... Alas. What follows assumes the Borland TRichEdit control. I don't know what it is in VC++, but the main functionality is in the Perform() function, which just calls the richedit's Window Procedure. You can use SendMessage() instead if you like, but calling the WndProc directly would be more efficient.

Alas, I've never done any serious Win32 programming with MSVC++... (having preferred Borland's tools), and it is late so if you are still stuck a day or two from now I'll try to look up an answer that better addresses your compiler.
[/edit]

The TRichEdit control inherits a method called Perform(). You can use this with the EM_FINDTEXTEX message.

bool FindTextEx(  // returns whether or not the text was found
  TRichEdit& red,
  const std::string& text,
  bool               is_search_forward,
  bool               is_match_case,
  bool               is_match_word
  ) {
  CHARRANGE  sel;
  FINDTEXTEX ftinfo;
  UINT       flags = 0;

  // Set the range to find from the cursor to EOF (or BOF)
  red.Perform( EM_EXGETSEL, 0, &sel );
  ftinfo.chrg.cpMin = sel.cpMax;
  ftinfo.chrg.cpMax = is_search_forward ? -1 : 0;

  // Text to find
  ftinfo.lpstrText = text.c_str();

  // Flags
  if (is_search_forward) flags += FR_DOWN;
  if (is_match_case)     flags += FR_MATCHCASE;
  if (is_match_word)     flags += FR_WHOLEWORD;

  // Find it
  if (red.Perform( EM_FINDTEXTEX, flags, (LPARAM)&ftinfo ) == -1)
    return false;  // (return = no more matches)

  // Update the …
Duoas 1,025 Postaholic Featured Poster

Wrong forum.

GWBASIC doesn't have a recursive KILL command. You'll have to write a subroutine that does it yourself.

  1. Use FILES to get all the file names in the target directory.
  2. For each filename:
    • if it is a directory (name is followed by "<DIR>", for example "C:\FOO\MYSUB<DIR>") then recurse.
    • otherwise use KILL
  3. When done, RMDIR the current directory

Remember to specify an error handler or turn it off or use RESUME before trying to delete files (since the OS may disagree and cause an ERROR to be signaled).

I wonder if SHELL "DEL/S ..." would work? The specification specifically refers to COMMAND.COM, which I think isn't supposed to have the /S option. You could also try SHELL "RD/S/Q" (which is an XP command).

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I don't use Word, so I can't help... but what you are doing is unlikely to work well anyway because the window class names can change between versions of Word... But I think you should be looking for a RichEdit class...

I think you ought to look at OLE automation.
Here's a page all about word
http://www.kayodeok.btinternet.co.uk/favorites/kbofficewordhowto.htm

Search down near the bottom in "How to automate word" for "paste".

The other option would be to send the proper keyboard sequences to Word to access the Edit|Paste menu item.

Sorry I can't be of more help.

Duoas 1,025 Postaholic Featured Poster

What object is getpixel part of?

Also, if you mean the (X, Y) under the cursor, you'll have to use the MouseDown event.

Are you trying to get the color of a pixel in an image you loaded in your program? Or are you trying to get the color of a pixel of another program?

Duoas 1,025 Postaholic Featured Poster

You do realize that this thread is over three years old?

...And that using goto for this instead of a loop is Wrong...

...And that this is the Pascal and Delphi forum...

(But at least you didn't call main(); ;) )

Duoas 1,025 Postaholic Featured Poster

Yes... such applications are still made.

And no, the syntax doesn't change. The paradigm may change... All GUI programs (well... all good ones ;) ) are event-driven. Console programs tend to be imperative (though many good ones are also event-driven).

The goal is to learn to properly use the language. That can be done in any UI environment, so for beginners it is usually easier to leave out all the overhead required to make GUI programs and stick to the C++ language itself instead of dinking around with external libraries.

There is no reason why you can't start with GUI programs though... Proper use and good design is important either way.

Duoas 1,025 Postaholic Featured Poster

In practice it doesn't impact performance.

What it does is make your code more usable, more correct, and easier to read.

All you ever wanted to know about const correctness
http://www.parashift.com/c++-faq-lite/const-correctness.html
http://cprogramming.com/tutorial/const_correctness.html
http://www.possibility.com/Cpp/const.html

For good measure, here's an example where it makes a difference:

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

void reverse_print_const( const string& s )
  {
  cout << "const: ";
  for (string::reverse_iterator c = s.rbegin(); c != s.rend(); c++)
    cout << *c;
  cout << endl;
  }

void reverse_print_non_const( string& s )
  {
  // Take note that the function body is exactly the same as above
  cout << "const: ";
  for (string::reverse_iterator c = s.rbegin(); c != s.rend(); c++)
    cout << *c;
  cout << endl;
  }

int main()
  {
  string message = "Hello world!";

  // Both of these work just fine
  reverse_print_const( message );
  reverse_print_non_const( message );

  // But this fails for the non-const
  reverse_print_const( "!sseccuS" );
  reverse_print_non_const( "...eruliaF" );  // <-- this line won't compile!

  // The reason why is that the const char* is
  // type-promoted to a const string temporary
  reverse_print_const( string( "!edud suoethgiR" ) );
  reverse_print_non_const( string( "...remmuB" ) );  // <-- same here

  // We can test it the same with a const message
  const string message2( "Good-bye." );
  reverse_print_const( message2 );
  reverse_print_non_const( message2 );  // <-- same here

  return 0;
  }

What this should make clear is that the compiler is free to use the const version of the function in all circumstances, …

William Hemsworth commented: Good Post +2
Duoas 1,025 Postaholic Featured Poster

NCurses.

Win32 (PDCurses)
Unix (NCurses)

You can also use the Win32 Console API directly.

Have fun! :)

Duoas 1,025 Postaholic Featured Poster

You should also be very careful about const-correctness.

Insertion operators should generally have the form: ostream& operator << ( ostream&, [B]const[/B] myobj& ) and extraction operators should generally have the form: istream& operator >> ( istream&, myobj& ) There are, of course, exceptions, but you don't need to worry about them now.

Duoas 1,025 Postaholic Featured Poster

Right. The va_args don't work with object-types.

Duoas 1,025 Postaholic Featured Poster

You'll also need to #include <iterator> if you want to use those back_inserters properly.

The lexicographical_compare() algorithm optionally takes a fifth argument: a boolean predicate. You can make your custom predicate do a case-insensitive comparison by converting both arguments toupper() before returning whether a < b.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Isn't there a Files property (which should be a TStringList or somesuch)?

Duoas 1,025 Postaholic Featured Poster

Newsgroups are archived. For ever and ever. (But they are annoying to search.)

Yes, I already tried WH_CALLWNDPROC with no luck. Please, see the file attachment to my first message.

No, you tried WH_CALLWNDPROCRET, which is entirely different.

If you are still having problems I'll see if I can't compile your code myself and figure out what's wrong.

Duoas 1,025 Postaholic Featured Poster

Olvidaste poner conullas al seis. while (producto != '6') :$

Hope this helps.

VernonDozier commented: Showoff! :) +5
Duoas 1,025 Postaholic Featured Poster

I have never played directly with Qt stylesheets... but it appears that you need to provide an image for the indicator with the color you want. Here's what I found about it:
http://lists.trolltech.com/qt-interest/2006-11/thread00074-0.html
The OP wants to manage different colors for different states, but the underlying problem is the same. There's also a nice link in there to the Qt examples.

While annoying, it shouldn't be too much to create little images that will do the job. Qt makes it particularly easy to include image resources in your project.

The only other way is to completely paint the radiobutton yourself.

Sorry there isn't a simpler answer.

Duoas 1,025 Postaholic Featured Poster

I'm sorry, I mixed-up that last two arguments to SetWindowsHookEx() and thought you were installing a process hook.

The WM_SHOWWINDOW message is not a queued message --it is sent directly to the target window procedure. Hence, the WH_GETMESSAGE hook will never see it. You'll need to install a WH_CALLWNDPROC hook to catch it.

Annoying, isn't it?

(Sorry it took me this long to pay enough attention to answer your question...)

Duoas 1,025 Postaholic Featured Poster

You have to hook external objects using global hooks (those residing in a DLL). Process hooks can only be used with your own application's processes.

Duoas 1,025 Postaholic Featured Poster

Since you are compiling with the UNICODE flag, you must either indicate that string literals are wide-char directly: L"Hello world!" or (better yet) use the TEXT() macro: PlaySound(TEXT("beep.wav"), 0, SND_LOOP|SND_ASYNC); Have fun.

Duoas 1,025 Postaholic Featured Poster

There is nothing wrong with it. You'll just get a reference to a temporary default.

The best advice is to write const std::string& error = std::string() as your argument. This will take strings and char*s equally.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

You haven't told the compiler what a vector is, so it considers it an unknown type and goofs-up.

Either add a using std::vector; somewhere at the top, or say std::vector <Car*> foo(); Hope this helps. (Isn't it annoying when the silly stuff gets you?)

[edit] BTW, the header file should also #include <string> #include <vector> and not rely on the using program to do it for you.

Duoas 1,025 Postaholic Featured Poster

That's called an operator overload.

The << and >> operators are bit-shift operators, but in C++ the STL uses them with iostreams as insertion and extraction operators.

In other words: cout << "Hello world!" << endl; cout is the left object
<< is the operator
"Hello world!" is the right object

The operator writes the right object to the left object stream, and returns the left object (cout), so what remains to be done is: cout << endl; Again, cout is the left object
<< is the operator
endl is the right object

The operator writes a newline to the left object stream and flushes it, and returns the left object (cout).

This is a convenient idiom, so you can use it to do things like:

struct point_t
  {
  int x, y;
  point_t( int x = 0, int y = 0 ): x( x ), y( y ) { }
  };

point_t p( 10, -7 );

cout << "The point is " << p << endl;

Unfortunately, C++ doesn't know anything about how to write a point to cout, so you have to tell it how by overloading the << operator to work on a point_t.

ostream& operator << ( ostream& outs, const point_t& pt )
  {
  // write the right object (pt) to the left object stream
  outs << '(' << pt.x << ',' << pt.y << ')';
  // return the left object stream
  return outs;
  }

When …

Duoas 1,025 Postaholic Featured Poster

The linker is complaining that you didn't link in the execprocess.obj object data.

If you are using the GCC from the command-line, make sure to compile as: g++ -Wall -o extProg extProg.cpp execprocess.cpp If you are using VC++ or C++Turbo or some other IDE, make sure you add execprocess.cpp and execprocess.hpp to the project before compiling.

It looks cryptic, but ld is the name of the linker on *nix systems (and also with the GCC on all supported systems). A non-zero exit status means something went wrong...

The complaints about "undefined reference to X" means that the compiler knows what X is, but it cannot find X. Since X is defined in another cpp file, that file must be compiled and linked to the cpp file containing main().

For example: g++ -Wall -c execprocess.cpp (compile to "execprocess.o") g++ -Wall -c extProg.cpp (compile to "extProg.o") g++ extProg.o execprocess.o (have GCC tell the linker connect the two object files into a single executable file)
Since extProg.o uses stuff in execprocess.o, the linker puts them together so that it will work.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I've answered this question (on another forum ... :sweat: ) with a little class to do this kind of thing. You can look through it to see how it works (or just use it as-is --whatever you like). It is POSIX compliant (meaning it will work on any POSIX platform) and uses fork() and exec() to do its stuff.
http://www.cplusplus.com/forum/unices/2047/#msg7731

It doesn't matter what language was used to write the program you want to execute.

Now, if you actually want to communicate with the child in some way (like using popen() or some other form of IPC) that will involve more work, but let us know.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

What you have written is a data class, and either your professor will have you extend it or will have you write a templated linked-list class and use Contributor in a linked list.

I've really only barely glanced at it, and most everything seems to be in order but one:

Serialization
Yep. It's that word. :)

The word 'serial' indicates something that is arranged in a series. In meaning it is very like the word 'sequential'. A serial port on your computer, for example, doesn't send all the information at once, but one 'word' at a time (be that a byte or an integer or whatever). A serial killer is someone who murders over and over again. He doesn't kill a lot of people all at once and be done with it. In all cases, we can speak of the objects (or people) by number. The first byte. The second byte. Etc. The last victim. The penultimate victim. Etc.

A file stream is a serial device. It is an ordered collection of data. A text file represents characters that are ordered to something humans can read. An exe (win) or elf (nix) file represents a collection of codes that are ordered to something the computer can read. Etc.

So, to serialize your class means to take your entire object (which exists all at once) and turn it into discrete, ordered elements that can be sent over a serial device (like an I/O port or …

Duoas 1,025 Postaholic Featured Poster

That's not a problem. Underneath a std::string or a std::vector is just an array anyway, except that all the nasty details of managing it are taken care of for you.

So, yes, use c_str() to get a const char* back that you can use with functions that take them. If your STL is implemented "properly" (IMO) then it shouldn't cost you anything to do it that way.

It looks like the second problem is that I accidentally typed << twice in a row. You can't have two binary operators in a row without an interleaving argument. It has nothing to do with strings. So, change line 32 to:

cout << "char " << i << ": " << c << '\n';

Sorry about that! :$

Duoas 1,025 Postaholic Featured Poster

When you overload stream operators such that they take two arguments, you have to declare them friend or they, like any other foreign object, will not be allowed to tinker with the object's internals.

class foo
  {
  private:
    int i;
    ...
  public:
    friend ostream& operator << ( ostream&, const foo& );
  };

ostream& operator << ( ostream& outs, const foo& f )
  {
  ostream << f.i << endl;  // or whatever
  }

Sorry about that. I should have noticed and warned you about it.
:$

Duoas 1,025 Postaholic Featured Poster

For the OP, the security danger is in executing less-privileged programs with more-privileged programs. That is, a low-level hax0r can write malicious code and get someone with access rights he doesn't have to execute his program. Doing so gives the executed program all the access rights as the calling program, and the maliciousness is unbounded.

Typically, programs will execute others under [edit]three[/edit] scenarios:

  1. As a user tool.
    Programs like Explorer or ObjectDock/Launcher/whatever or Irfanview, WinAmp, etc. need to execute other programs in order to satisfy the user's instructions. Explorer runs the program you double-click. Irfanview uses the QuickTime Player to play .mov files. Etc.
  2. As part of a known software system.
    For example, your IDE lets you edit programs: it may use OLE to embed an editor. It calls the compiler and linker and even programs like make to execute scripts that compile and link your program. The fancy GUI program you are using may only display the GUI and interact with the user. It could be actually doing stuff by executing other executables that came with the GUI. Often, the GUI itself is an external program. GIMP, for example, uses GTK, which is provided via a nice DLL sitting in your system32 directory. If you like Linux, your fancy calculators all farm out to bc to do the math. Etc.
  3. As an extension/add-on/plug-in/interpreter to add functionality to a program.
    For example, Softimage|XSI uses Perl to allow users to write scripts that do things the …
Duoas 1,025 Postaholic Featured Poster

Heh, don't feel bad. Nothing is obvious until you see it. You'll do fine.
:)

Duoas 1,025 Postaholic Featured Poster

Just a quick glance it looks OK.

The insertion operator prototype should list its second argument as const: ostream& operator << (ostream& out, const Contributor& InContributor) What makes one Contributor less than another? Answer that and you can write the contents of your < operator.

Hope this helps.

[edit] Oh yeah, your assignment operator's insides should look very much like your copy constructor's insides.

Duoas 1,025 Postaholic Featured Poster

Salem is right. I almost said something about that myself but it has been a while since I've used select() and I forgot you aren't waiting on stdin (even though your comments say you are).

To wait on the FIFO, your call should be retval = select(i+1, &fd, NULL, NULL, &tv); Typically, file descripter variables are named something like "fd". A file descriptor set variable is typically named "fds".

Hope this helps.

[edit] Oh yeah, also remember that you can't read anything until something is first written.

Duoas 1,025 Postaholic Featured Poster

There is nothing inherently evil about system(), or executing other executables; just be aware that you must be careful how you do it.

Duoas 1,025 Postaholic Featured Poster

They will remain separate programs, but I think you are asking if your C++ program can automatically run the VBA program so that the user doesn't have to?

You have a variety of options. You can use system() (#include <cstdlib>). system( "\"C:\\Program Files\\MyVBAProgram\\VBAProg.exe\"" ); On Windows you can use ShellExecuteEx() (there are examples on MS's site), and WaitForSingleObject() on the hProcess member of the SHELLEXECUTEINFO structure. (#include <windows.h>).

Or you can use CreateProcess() directly...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

"Overloading" (at least in C++) means that you have more than one function with the same name. In this case, you have three different constructors, but they all have the same name.

The difference is the number and type of arguments it accepts.
The first takes no arguments, so it is the default constructor.
The second takes a list of values to initialize the class, so it is an initializing constructor.
The last takes a reference to another object of the same type (or 'class'), and copies its values, so it is a copy constructor.

In the body of the default constructor, you gave all your object's variable fields default values.
In the body of the initializing constructor, use the arguments to assign values to your object's variable fields.

Keep in mind that since the argument and the field names are identical, you must use this to refer to the object's fields: this->Donation = Donation; Hope this helps.

Duoas 1,025 Postaholic Featured Poster

You need to rethink why you are using a loop.
Ideally, if you have to do things multiple times, it suggests a loop and/or an array.

Since you need to remember five numbers, instead of writing: int num, num1, num2, ... you can instead just use an array: int items[ 5 ]; I would have named it "numbers": int numbers[ 5 ]; (But I'll still use "items" below.)

Now below, you want to read 5 numbers (and remember them). You've got a nice loop there that counts from 0 to 4, and a nice array, so let's put them together:

for (counter = 0; counter < 5; counter++)
  {
  cin >> items[ counter ];
  }

You've already got a nice loop there that counts from 5 to 0. You'll have to fix that five to the proper number to start at. (Remember, arrays are index from 0 to N-1, where N is the number of elements in the array.) And I think you should know by now what goes inside the loop.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The only two things I see that are guaranteed problems are first in EnterName(). You should input text using getline().

void WordRead::EnterName()
{
	cout << "Type in the text file path you wish to read: ";
	cin.getline( theFile, 1000 );
}

And second in LoadFile(), your loop will never terminate if you never hit EOF (which can happen if a read error occurs). A better idiom is to terminate if the istream indicates any failure.

for(int i = 0; myFile.good(); i++)

But you've also got another problem. Even if you hit EOF, you still try to add a character to the end of your vector. As an added note, using the class variable ch is much slower than using a local char variable. Below I suggest something better for you.


You should really consider making use of the STL string library. That will make things much easier, and you'll get better performance than a vector of char.

I think you need to work on your variable names also... Variables should be nouns, and functions should be verbs. Both should be descriptive of what it represents.

...
#include <string>

...

private:
	// This is more descriptive: it tells you it is the
	// file's -name-, and not some other thing.
	string theFileName;
	// Fine
	ifstream myFile;
	// Again, this tells you that it is the file's text.
	// 'load' is a verb, and is doubly confusing when
	// used anywhere other than in LoadFile(). …
Duoas 1,025 Postaholic Featured Poster

If you are using the Express edition, you can't.
If you purchased VS, then call the MS support and ask.
Sorry.

Duoas 1,025 Postaholic Featured Poster

The FIFO will never have input until you write something to it. Since you don't write anything to it, select() will always say that there is no input waiting.

Remember, a FIFO must be open at both ends (which you have done), and to read data you must first write data (which you haven't done).

Hence, the first example works because you write, then read. The second fails because you never write before select()ing to read.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

You have discounted newline conversions.

On Windows, the newline character represents the ASCII sequence CR LF.
When your program reads it, it gets '\n'. The newline is encrypted thus and so the output file is shorter than the input file, because the encrypted data doesn't have as many '\n's (if any) as the source.

You'll also notice that when it says File Length: that it gives the shorter size.

When decrypting, you get back that '\n', which is written to file as CR LF, thus increasing the output file size (back to the original size).


Some observations:
<conio.h> is evil.
Use functions.


Hope this helps.