|
How can I add a carriage return at the end of a CString?
|
|
|
|
|
CString s;
s += _T("\n");
s += _T("\r\n");
Steve
|
|
|
|
|
Thanks a lot. I don't know why I didn't think of that.
|
|
|
|
|
isn't \n\r work or \r\n ..!
"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
|
|
|
|
|
It depends on what the string will be written to. If it's a text file, use \r\n uness you're going to be using the C I/O functions, in which case use \n and let the CRT change it to \r\n on its own. For multi-line text boxes, use \r\n .
\n\r is never right.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Michael Dunn wrote: \n\r is never right.
Right
"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
|
|
|
|
|
Can Any one please tell me how can I compile and see the result(on the screen) of the following program using VisualStudio?
include<stdio.h>
main()
{
int i=3;
int*j;
j = &i;
printf("The value of i=%d",*j);
}
|
|
|
|
|
Though I personally use streams (cout) for my programs at school, and I am not familiar with the printf() function, If you are using VC++.Net, I think you actually have to put a system("pause"); at the end of your program or it will not remain open long enough for you to see anything... other than that, you'll have to wait for someone else to answer. I hope it helps!
sincerely, Brett Peirce - PolerBear
To err is human; To forgive: divine.
|
|
|
|
|
use getch() function at last,declare in conio.h
|
|
|
|
|
Hi! I have a template function problem.
This is what I tried to do:
First, I created a .lib file called writeValue.lib, using this source code:
<br />
#include <iostream><br />
<br />
template <class T><br />
void __cdecl writeValue( T value )<br />
{<br />
std::cout << value << flush;<br />
}<br />
Then, I tried to build a Win32 Console Project, in which I put a single file called main.cpp, containing the following lines:
<br />
template <class T><br />
extern void __cdecl writeValue( T value );<br />
<br />
#pragma comment( lib, "writeValue" )<br />
<br />
int main( void )<br />
{<br />
writeValue <int> ( 10 );<br />
<br />
return 0;<br />
}<br />
It compiles, so I get a main.obj, it links writeValue.lib, but I get a link error when I try to use the writeValue( ) function with an integer parameter:
error LNK2019: unresolved external symbol "void __cdecl writeValue<int>(int)" (??$writeValue@H@@YAXH@Z) referenced in function _main
- even though the writeValue( ) function is defined (as a template) in the writeValue.lib file.
All was done in Microsoft Visual Studio .NET Professional 2003.
Can anyone help me with this, please? Thank you!
|
|
|
|
|
|
I want to invoke a certain method when a edit control is double clicked, but i cant seem to find any info on the event handling that i need to do. Any help would be appriacated, thank you.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Is this MFC or not?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Yea, MFC. Using .NET '02
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
I would instruct you to use ClassWizard, but that does not exist beyond VS v6. I think it has been "replaced" with a properties-type of thing. In any case, You'll need a ON_BN_CLICKED() entry in the dialog's BEGIN_MESSAGE_MAP() method. Don't forget to implement the handler function.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I tried that. It complies fine, but when its running i tried it out, and it never reachs my method that i attached to it through the ON_BN_CLICKED() method... As of now im just grabbing the cursor on any double click, and having to compare to where my edit controls are, but this seems way to complex for something that i feel should an easier way..
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
See the example here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I have a dialog with several controls in it for several miscellaneous functions. Among them, I created a pushbutton control (function) which, when entered, loops forever processing the following:
opens a file, processes file data, closes the file, sleeps to
allow file access and repeats within the loop.
Once I select the pushbutton to do this, it locks me out from any of the other controls. How can I suspend (etc.) the loop to allow me to tell if another control has been selected and, if so, leave this loop to process the selected control.
Thanks, Ron
|
|
|
|
|
ronwurster wrote: opens a file, processes file data, closes the file,
You need to put this code in a worker thread.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
hi everyone!
I have a question regarding input and output with files (standard C/C++).
Whenever I use the 'getline' function to get a line from a file and then ask the
program to display that line, it always displays more than a line.
In other words: it doesn't stop 'getting the line' whenever it encounters a
newline.
How can I make sure he reads only one line and no more?
And how can I tell the program to get a specific line, like line n° 34
or the line that follows the words 'myline:' or whatever?
Thanks in advance!
Peter
The program that's supposed to get one line but gets more then that is this one:
<br />
#include <iostream><br />
#include <fstream><br />
#include <string><br />
using namespace std;<br />
<br />
int main () {<br />
string line;
ifstream myfile ("example.txt");<br />
if (myfile.is_open())
{<br />
while (! myfile.eof() )
{<br />
getline (myfile,line);
cout << line << endl;
}<br />
myfile.close();
}<br />
<br />
else cout << "Unable to open file";
<br />
return 0;
}<br />
<br />
|
|
|
|
|
Peter Charlesworth wrote: Whenever I use the 'getline' function to get a line from a file and then ask the
program to display that line, it always displays more than a line.
What do you mean? I tried your code verbatim and it worked fine.
Peter Charlesworth wrote: In other words: it doesn't stop 'getting the line' whenever it encounters a
newline.
It did for me. What was printed to the console window looked exactly like the contents of the file.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Well, what I'm trying to accomplish is this:
Suppose a file named "example.txt" has this as content:
<br />
This is line one.<br />
This is the second line.<br />
As you can guess, this is the third line.<br />
And i run the program i mentioned above, then it would output this:
<br />
This is line one.<br />
This is the second line.<br />
As you can guess, this is the third line.<br />
But it's supposed to output this:
<br />
This is line one.<br />
Getline... Get one line and then execute the next piece of code, but instead
it gets the contents of the entire file.
I use Borland C++ 5.5 as my compiler, maybe that my problem is a problem just with my
compiler.
Anyway, thank for responding!
Peter
|
|
|
|
|
So get rid of the while() loop and see what happens. If what you say is true, then a single call to getline() /cout will display the entire file.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
How could I have overlooked that while() loop?
A very stupid human error...
Well, I'm a novice for something, eh?
Thanks, David!
|
|
|
|