|
Mark_Murphy wrote: myfile.getline(yy,100, 'n');
That should be myfile.getline(yy, 100, "\n"), or simply myfile.getline(yy, 100); ('\n' is the default 3rd parameter).
Alternatively, you could use the generic getline method:
string name;<br />
getline(myfile, name);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Excellent Zac
The
string name;
getline(myfile, name);
worked perfect, the other suggetions gave errors on compiling.
Leave you guys in peace now
Thanks for the help much appreciated !!!
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
Oops...sorry, I don't really use this stuff.
Should've been:
myfile.getline(yy,100,'\0');
This way the file read will quite when it hits a null char.
SEE:
Input Stream Member Functions[^]
and
istream::getline[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
No worries EricDV
Thanks for the info and the links, will go read up the stuff for a while now ( maybe confuse myself a little further lol ). Its been 4 days now since i started with C++ and just finished my first program. All I got to do now is tweak the code a little and try to improve it.
So many thanks for your help today !!!!
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
if project had multi CDocument class which class is first handle
menu massage such as Open File ....
i try that my default class is CFirstDocument , other is CMyDocument ,
i i create menu as name "Open Image File..." & handle message in CMyDocument
when program execute ,"Open Image File..." is disable !!!
but when i handle it from CFirstDocument that is active !
how can i change these setting & what is order of handling messege in these case?
Best Regards.
MJM.
|
|
|
|
|
I don't have a Windows platform around to verify this, but I *believe* that the first document template you add to the app in InitInstance() method will be the default document type. Change that order if it is not the document type of your choice.
Best,
Jun
|
|
|
|
|
i change order but nothing happen!
i try to search to how order for handling messages!
for MDI:
1)active view object
2)the document object for the active document
3)the document template object for active document!!!
4)the frame window object of active view
5) main frame window object
6)the application object
// Thanks Ivor Horton's book!
for sdi because have one active frame it is obviously what order is!
in my code i have Dockable window that create dynamically .
in my code with CCreateContext & CFrameWnd::Create... create Frame & related view & attach them to document dynamically!
it is seems that when i create new Frame can not be active frame because after i create pane i
get active view for MDI code such that:
<br />
CMDIFrameWnd *pFrame1 = <br />
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;<br />
<br />
CMDIChildWnd *pChild = <br />
(CMDIChildWnd *) pFrame1->GetActiveFrame();<br />
<br />
<br />
CView * pView = pChild->GetActiveView();<br />
after debug i see pView is kind of another view that i create for pane!!!!
i try to active new frame with pFrame->GetParentFrame()->ActiveFrame(SW_RESTORE);
but nothing happen.
i have tree view class & two Document class & three template.
|
|
|
|
|
You have not specified whether the application is SDI or MDI and you have not specified what each document is for.
Is this a MDI application and is each child window a separate image? If so, then perhaps an article I wrote would help. Otherwise explain a bit more what the application is doing, especially about how the document is used.
|
|
|
|
|
File-Open is usually handled by the main frame. If you have multiple document types then the statndard behaviour is present to the user a dialog where they can choose which document type to open. The same applies for File-New.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
after some try i found , error is from my view class !!!
default CView class work properly !!! but own class that
i derived have problem when i try to OpenDocument from another
template , other CView do not work properly!
|
|
|
|
|
OK guys I received a project from a buddy, needs some work on it; however it's a sln project file in 2005 and I use 2003. I really do not want to have to install 2005, as I have no need to upgrade right now. I have seen other converters, but none to go from 2005 to 2003. Is there any other solution? Thanks.
|
|
|
|
|
I don't know of a converter, but my past experience with similar converted has been that it's better to recreate the base project with the previous IDE and then bring the files in.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
how to write a code to control the surround volumn for each?
please give me some idea and example
|
|
|
|
|
Hi!
I'm making an extension for a program (MMF2) and have run in to some problems...
The user can load a DLL, set the arguments and the call a function. All of theese at runtime. I push my values on to the stack and call the function.. That works fine.. the problem occurs when I try to pop the arguments of the stack (Need this if anyhing has changed, for instance when calling GetWindowText())...
I know the cause of this.. In MMF2 all function calls are __stdcall (or WINAPI)... Is there any workaround for this??
This is how a function looks in the SDK
long WINAPI DLLExport Function(LPRDATA rdPtr,long param1) {<br />
return 0;<br />
}
I call my function from within this function (my function is not __stcall, it's __cdecl)
Does anyone have a solution??
EDIT: I use asm for the function calling btw!
-- modified at 10:53 Thursday 14th September, 2006
|
|
|
|
|
use EXTERN "C"
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Thanks for your answer... Unfortunately this did'nt work!
|
|
|
|
|
I'm not very sure how to code this one. I have a base class and 3 derived classes. All of the derived classes need use of a timer, which I think is best to place in the base class. Is it possible for the baseclass to call derived class functions?
|
|
|
|
|
Yes, if you declare the function virtual, then if the function is redefined in the derived classes, this one will be called.
|
|
|
|
|
|
Hey, what Cedric said is called "polymorphism", which works only when you use pointers to reference objects. So this would call the overridden method:
YourBaseClass *p = new YourDerivedClass();
p->SomeFunction();
But this wouldn't:
YourBaseClass obj;
obj.SomeFunction();
Best,
Jun
|
|
|
|
|
waldermort wrote: All of the derived classes need use of a timer, which I think is best to place in the base class. Is it possible for the baseclass to call derived class functions?
Beware Active Derived Class member will receive the call!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
waldermort wrote: All of the derived classes need use of a timer, which I think is best to place in the base class. Is it possible for the baseclass to call derived class functions?
Beware Active Derived Class member will receive the call only
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi
Can anyone give me any guide lines as web searches have been unsucessful
I want to be able to save input from a console application to a text file.
eg: if a user inputs their "name" via cin on the console, how do you save the name to a text file.
I have just started learning if/ofstream classes and have a basic understanding, so if you could show me some examples of the code to save the input to a text file I would be grateful. Also I wish to append new data to the same file so if you could also advise me if the use of "ios::app" is the correct way of doing this without over writing old data.
Thanks in advance.
The problem with political jokes is they get elected.
|
|
|
|
|
To use ofstream the way you specified:
char name[20] = {0};
ofstream fout;
fout.open("mylog.log", ios::app);
cin >> name;
fout << name;
fout.close();
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Cheers Zac
Thanks for the prompt response.
Worked first time on your advise.
Many thanks.
The problem with political jokes is they get elected.
|
|
|
|