|
You just follow discussions. Usenet newsgroups like comp.lang.c++.moderated and comp.std.c++ are two very good sources. C/C++ Users Journal also contains some info.
|
|
|
|
|
When run through the command line my program prints a usage message and then I type in the file name I want it to perform fopen call on. It then performs writes to this file.
When I click the icon I just get a quick flash on the screen. i tried checking the properties to see if I could change how the program is run but it will only let me view the general prperties.
|
|
|
|
|
Are you processing somehow the commandline parameters stored in argc and argv ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes I am taking an infile.txt and compression it it outfile.txt. under Huffman compression.
It works fine when I run it from the ms-dos command line but not when I double click the icon. Any ideas would be much appreciated.
|
|
|
|
|
Klara wrote:
Yes I am taking an infile.txt
Aha! That's where the error is. You assume that infile.txt is in the current directory. You forget that when you run from windows the current directory need not always be the executable's directory.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Yes, when I run it from the command line I always have to type
cd C:\pathname\ and then type Myprog.exe
Then the path is chnged to where the exe file is and then I can run Myapp.exe. The program then should print a usage message and I type infile(it is in the same location as the exe file) and I type the name of outfile which is placed in the same folder.
Any ideas how to fix the icon problem?
Thanks for your input though.
|
|
|
|
|
Klara wrote:
Then the path is chnged to where the exe file is and then I can run Myapp.exe. The program then should print a usage message and I type infile
So, basically the first thing your program does is to display a message on the console. Then it reads the name of the infile followed by the name of the outfile. Is that what it does?
And what you say is that you don't even get the prompt to enter the file name, correct?
Could you please post the relevant code snippets upto this point in your code?
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
I don't get a prompt unless I runn it through the commandline, so at least I know the program works.
The main() routine supplied here has the job of checking for valid input and output files, opening them, and then calling the compression routine. It expects to find a compression routine in another module. If the files are not present, or no arguments are supplied, it prints out an error message, which includes the Usage string supplied by the compression module. All of the routines and strings needed by this routine are defined in the MAIN.H header file. I have included some explanations of the various modules further down.
I don't get a prompt unless I runn it through the commandline. This is part of my main program.
*/ This is the usage message
Usage:DOHUFF infile.txt outfile.txt
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bitio.h"
#include "errhand.h"
#include "main.h"
void usage_exit( char *prog_name );
void print_ratios( char *input, char *output );
long file_size( char *name );
int main( argc, argv )
int argc;
char *argv[];
{
BIT_FILE *output;
FILE *input;
setbuf( stdout, NULL );
if ( argc < 3 )
usage_exit( argv[ 0 ] );
input = fopen( argv[ 1 ], "rb" );
if ( input == NULL )
fatal_error( "Error opening %s for input\n", argv[ 1 ] );
output = OpenOutputBitFile( argv[ 2 ] );
if ( output == NULL )
fatal_error( "Error opening %s for output\n", argv[ 2 ] );
printf( "\nCompressing %s to %s\n", argv[ 1 ], argv[ 2 ] );
printf( "Using %s\n", CompressionName );
CompressFile( input, output, argc - 3, argv + 3 );
CloseOutputBitFile( output );
fclose( input );
print_ratios( argv[ 1 ], argv[ 2 ] );
return( 0 );
}
/*
* This routine just wants to print out the usage message that is
* called for when the program is run with no parameters. The first
* part of the Usage statement is supposed to be just the program
* name. argv[ 0 ] generally holds the fully qualified path name
* of the program being run.
*/
void usage_exit( prog_name )
char *prog_name;
{
char *short_name;
char *extension;
short_name = strrchr( prog_name, '\\' );
if ( short_name == NULL )
short_name = strrchr( prog_name, '/' );
if ( short_name == NULL )
short_name = strrchr( prog_name, ':' );
if ( short_name != NULL )
short_name++;
else
short_name = prog_name;
extension = strrchr( short_name, '.' );
if ( extension != NULL )
*extension = '\0';
printf( "\nUsage: %s %s\n", short_name, Usage );
exit( 0 );
}
|
|
|
|
|
What's happening is that since argc < 3, your program displays the usage message and exits.
Right click on the icon of the execuatble in explorer. You should get a properties tab window. Select the "Program" tab. There will be an edit box where you are supposed to enter the full command line. If you have any arguments you should append those arguments to the full path of the executable.
Eg:- C:\abc\myexe.exe file1.txt file2.txt /r:100
Regards,
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Thanks for the help, I'm gonna try that out now.
|
|
|
|
|
Hey Nish,I'm still getting problems with this icon. When I right click on it I get the general properties only and nothing else. The check box is set to archive and there are no other tabs so I can't change the path name.
Any other ideas
|
|
|
|
|
Are you reading from a file, assuming it is in the same directory as the exe file? When you run it from windows the current directory might vary.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
As an aside, why on *earth* are you using fopen instead of iostreams ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I'm using fopen becuse its just what I'm used to, it's a school project and, we never learned anything about iosteams.
any ideas about the icon problem, its relly annoying me. When I set the active configurations of an ms-dos project should it be debug or release. Could this make a difference. I don't know what they are for.
|
|
|
|
|
Klara wrote:
I'm using fopen becuse its just what I'm used to, it's a school project and, we never learned anything about iosteams.
If you'll excuse me while I rant for a moment: this is precisely why there are so many bad programmers in the world, bad teachers. Why on EARTH would you teach someone C style file access instead of IOStreams ? Why do people get taught C style string handling instead of std::string ? Why ? Because they are being taught by C programmers trying to use C++ as a better C. It's not just C with classes anymore, and this style of teaching leads to bad coding habits, not to mention being harder to learn. Stroupstrup has said a lot about why C++ should not be taught this way, if only the academic world would catch up and stop teaching 1982 style programming.......
Klara wrote:
any ideas about the icon problem, its relly annoying me. When I set the active configurations of an ms-dos project should it be debug or release. Could this make a difference. I don't know what they are for.
The debug version requires debug versions of the librarys such as MSVCRT, which you most certainly need to fopen, so they will not run on machines that do not have a development environment on them. So you should compile for debug when you're writing the program ( it allows you to break and step through your code, reports memory leaks ( which are far more likely to happen in C than in C++ code ).
Is the problem that the program flashes up and disappears ? Maybe you need to put up a prompt to wait ? I'm sorry, I don't know how that is done in C.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
What switches should I specify to link.exe to generate a raw binary?
Also, can dumpbin disassemble a raw binary?
|
|
|
|
|
AFAIK you can only create PE's with link.exe. F.ex. how would you know where the different sections were using a "raw binary"?
|
|
|
|
|
Hi
Is it possible to execute a command in a unix server from VC++? I heard it can be done with telnet, but is there class or some library to do?
Regards,
Ravi
|
|
|
|
|
NT ships with rexec.exe - maybe that would do it...
|
|
|
|
|
I am trying to put messages out to the scren such that each line is under the next, causing a scrolling action in the window. I get the messages, but they are to the right of each other, even though I have CR/LF included, as well as WORDBREAK. In reading the function description, I thought the WORDBREAK and the \r\n would cause the output I desire. Can anyone please tell me where I am going wrong?
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
CRect rect;
char* data = " Dialing xxxxxx\r\n";
CWnd *wnd = dc.GetWindow();
::GetClientRect(wnd->m_hWnd, &rect);
dc.DrawText(data, strlen(data), &rect, DT_WORDBREAK);
dc.SetTextAlign(TA_RIGHT);
// Dialing the Host
pcAny.awConnect("xxxxxx");
rc = pcAny.GetError();
data = " \r\nConnection = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
dc.DrawText(rc, rc.GetLength(), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Getting Status of Connection
rc2 = pcAny.ConnectionStatus();
data = " \r\nConnection Status = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
itoa(rc2, data, 10);
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Sending the Order(s)
data = " \r\nSending Orders\r\n";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
pcAny.FileXferToHost("TESTFILE.TXT","TESTFILE.TXT");
rc = pcAny.GetError();
data = " \r\nSending = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
dc.DrawText(rc, rc.GetLength(), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Getting the New Catalog
data = " \r\nUpdating Catalog\r\n";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
pcAny.FileXferFromHost("CATALOG.TXT","CATALOG.TXT");
rc = pcAny.GetError();
data = " \r\nUpdating = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
dc.DrawText(rc, rc.GetLength(), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Host Disconnect
data = " \r\nDisconnecting from Host\r\n";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
pcAny.awDisconnect();
delete pcAny;
}
|
|
|
|
|
Only your current x pos will be updated when UPDATECP is set. The y-part will be returned from DrawText() (as a delta value) My guess is you have to do a manual MoveTo() to adjust the height. Not that I know for sure. What I do know for sure is that you only have to call SetTextAlign() once
|
|
|
|
|
Read that the WORDBREAK will only work when the UPDATECP is not set. Took them all out, but no change. Looks like the fucntion is fail to see the \r\n. Any other ideas?
|
|
|
|
|
If you just want to get the job done, use the CEditView derived from CView to display text. If that's not good enough (i.e. you want to do other drawing aswell), keep with your original ideas, but print just one line at a time, and keep track of the y-value yourself (just increase it with the height of your current font + some additional line spacing.
|
|
|
|
|
Hi, can any of you tell me how to disable property pages from displaying. Thank you!
|
|
|
|
|
Hello!
I need to know how to, when I maximize or minimize the size of the window of my program, make all that is inside the client area "maximize(or minimize)" together.
My problem is that I have a program which draws a picture in the client area, but when I maximize the window, the drawing disappears and I have to click a button or something like that in order to make the picture appears again.
I know that what I have to do is something related to the function "BitBlt" (if not or if there is another way, please tell me) and the procedure I must implement is to "take a photograph" of the drawing on the moment the user maximizes the window and then put this photograph onto the screen(which I believe is what "BitBlt" does), but I do not know how to make the code of this whole procedure (I've already tried, but it didn't work very well).
Thanks for any help!!!
|
|
|
|
|