I have a CString with 100 characters. Now i want to make that to 2
lines.
For example,
CString str = "This is just a test to find out how to break a
cstring";
I want this CString in the following format,
CString str1 = This is just a test to find
out how to break a cstring
ie, it should come in 2 lines.
I tried using line break (\n). But that doesn't work.
This was the code that i used.,
CString str = "This is just a test to find out how to break a
cstring";
int i = str.GetLength() ;
CString str1 = str.Left(i/2);
str1 += '\n';
str1+= str.Right(i/2);
str = str1; // But this is not working. It's not coming in 2 lines.
Is there any other way i can do this? 9 8105
On 2007-12-09 20:32, Donos wrote:
I have a CString with 100 characters. Now i want to make that to 2
lines.
CString is not part of the C++ standard library and thus off-topic in
this group, try asking in a group for Windows programming or MFC. Line-
breaks on Windows is usually represented by two characters, first a
carriage return and then a linefeed (\r\n), you could try using that.
--
Erik Wikström
Erik Wikström <Er***********@ telia.comwrote:
On 2007-12-09 20:32, Donos wrote:
I have a CString with 100 characters. Now i want to make that to 2
lines.
CString is not part of the C++ standard library and thus off-topic in
this group, try asking in a group for Windows programming or MFC. Line-
breaks on Windows is usually represented by two characters, first a
carriage return and then a linefeed (\r\n), you could try using that.
As I understand it, the \n "character" is defined as whatever it takes
to break a string into two lines.
Run time libraries may convert between the newline character and some
other character(s) (or lack of characters) during execution (such as
compacting the carriage return/line feed combination into the newline
character or generating the newline character at the end of a logical
record or transforming between various record separators and the
newline character).
( http://www.osdata.com/topic/language/cplus.htm)
Donos <do******@gmail .comwrote:
I have a CString with 100 characters. Now i want to make that to 2
lines.
For example,
CString str = "This is just a test to find out how to break a
cstring";
I want this CString in the following format,
CString str1 = This is just a test to find
out how to break a cstring
ie, it should come in 2 lines.
I tried using line break (\n). But that doesn't work.
This was the code that i used.,
CString str = "This is just a test to find out how to break a
cstring";
int i = str.GetLength() ;
CString str1 = str.Left(i/2);
str1 += '\n';
str1+= str.Right(i/2);
str = str1; // But this is not working. It's not coming in 2 lines.
Is there any other way i can do this?
What do you mean by "coming in 2 lines"? What does the following print
on the screen?
#include <string>
int main() {
std::string str = "This is just a test to find\nout how to break a
cstring.";
cout << str;
}
On Dec 10, 4:32 am, Donos <dongu...@gmail .comwrote:
I have a CString with 100 characters. Now i want to make that to 2
lines.
For example,
CString str = "This is just a test to find out how to break a
cstring";
I want this CString in the following format,
CString str1 = This is just a test to find
out how to break a cstring
ie, it should come in 2 lines.
I tried using line break (\n). But that doesn't work.
This was the code that i used.,
CString str = "This is just a test to find out how to break a
cstring";
int i = str.GetLength() ;
CString str1 = str.Left(i/2);
str1 += '\n';
str1+= str.Right(i/2);
str = str1; // But this is not working. It's not coming in 2 lines.
Is there any other way i can do this?
This an offtopic to this group.
Probably you may be needed to give "\r\n" (carriage return and new
line) to make in two lines. You can use the Insert or another useful
interface to insert the desired characters inbetween the string. So
that you can avoid creating temporary objects.
Regards,
Sarath
Daniel T. wrote:
Erik Wikström <Er***********@ telia.comwrote:
>On 2007-12-09 20:32, Donos wrote:
I have a CString with 100 characters. Now i want to make that to 2
lines.
CString is not part of the C++ standard library and thus off-topic in this group, try asking in a group for Windows programming or MFC. Line- breaks on Windows is usually represented by two characters, first a carriage return and then a linefeed (\r\n), you could try using that.
As I understand it, the \n "character" is defined as whatever it takes
to break a string into two lines.
Not exactly. It's defined as one signle character. The transformation
happens when doing file I/O in text mode.
On Dec 9, 8:46 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
On 2007-12-09 20:32, Donos wrote:
I have a CString with 100 characters. Now i want to make
that to 2 lines.
CString is not part of the C++ standard library and thus
off-topic in this group, try asking in a group for Windows
programming or MFC. Line- breaks on Windows is usually
represented by two characters, first a carriage return and
then a linefeed (\r\n), you could try using that.
It wouldn't be C++ if that were the case. In C++, a line is a
sequence of printable characters, terminated by a '\n'
character.
Any other representation of a new line is purely external to the
program, and is mapped in std::filebuf, if the file is opened in
text mode.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On Mon, 10 Dec 2007 05:31:36 -0800, James Kanze wrote:
On Dec 9, 8:46 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
>On 2007-12-09 20:32, Donos wrote:
I have a CString with 100 characters. Now i want to make that to 2
lines.
>CString is not part of the C++ standard library and thus off-topic in this group, try asking in a group for Windows programming or MFC. Line- breaks on Windows is usually represented by two characters, first a carriage return and then a linefeed (\r\n), you could try using that.
It wouldn't be C++ if that were the case. In C++, a line is a sequence
of printable characters, terminated by a '\n' character.
Any other representation of a new line is purely external to the
program, and is mapped in std::filebuf, if the file is opened in text
mode.
It's true if he tries to output his CString to a file, but maybe he tries
to show it on some label or text box.
--
Tadeusz B. Kopec (tk****@NOSPAMP LEASElife.pl)
Horner's Five Thumb Postulate:
Experience varies directly with equipment ruined.
On 2007-12-10 13:59:16 -0500, "Tadeusz B. Kopec"
<tk****@NOSPAMP LEASElife.plsai d:
On Mon, 10 Dec 2007 05:31:36 -0800, James Kanze wrote:
>On Dec 9, 8:46 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
>>On 2007-12-09 20:32, Donos wrote:
>>>I have a CString with 100 characters. Now i want to make that to 2 lines.
>>CString is not part of the C++ standard library and thus off-topic in this group, try asking in a group for Windows programming or MFC. Line- breaks on Windows is usually represented by two characters, first a carriage return and then a linefeed (\r\n), you could try using that.
It wouldn't be C++ if that were the case. In C++, a line is a sequence of printable characters, terminated by a '\n' character.
Any other representation of a new line is purely external to the program, and is mapped in std::filebuf, if the file is opened in text mode.
It's true if he tries to output his CString to a file, but maybe he tries
to show it on some label or text box.
Indeed. But standard C++ has neither a label (as the term is used here)
nor a text box. If some operating system has system calls that don't
handle C/C++ newlines correctly, the right place to discuss how to use
those system calls is a newsgroup that discusses that operating system.
--
Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
( www.petebecker.com/tr1book)
Pete Becker wrote:
On 2007-12-10 13:59:16 -0500, "Tadeusz B. Kopec"
<tk****@NOSPAMP LEASElife.plsai d:
>On Mon, 10 Dec 2007 05:31:36 -0800, James Kanze wrote:
>>On Dec 9, 8:46 pm, Erik Wikström <Erik-wikst...@telia. comwrote: On 2007-12-09 20:32, Donos wrote:
I have a CString with 100 characters. Now i want to make that to 2 lines.
CString is not part of the C++ standard library and thus off-topic in this group, try asking in a group for Windows programming or MFC. Line- breaks on Windows is usually represented by two characters , first a carriage return and then a linefeed (\r\n), you could try using that.
It wouldn't be C++ if that were the case. In C++, a line is a sequence of printable characters, terminated by a '\n' character.
Any other representation of a new line is purely external to the program, and is mapped in std::filebuf, if the file is opened in text mode.
It's true if he tries to output his CString to a file, but maybe he tries to show it on some label or text box.
Indeed. But standard C++ has neither a label (as the term is used
here) nor a text box. If some operating system has system calls that
don't handle C/C++ newlines correctly, the right place to discuss how
to use those system calls is a newsgroup that discusses that
operating system.
Or just ask the OP how he knows it's not two lines, what he's using to view
them. So OP, how do you know it's not two lines? Have you tried outputing
them to std::cout?
--
Jim Langston ta*******@rocke tmail.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rajesh Garg |
last post by:
Why and in what situations is CString not preferred?
RVG
|
by: Markus Hämmerli |
last post by:
I ' ll tra to convert a Cstring to char* without success.
I working in a Unicode enabled environment
this is working in Unicode
CString source = _T("TestString");
TCHAR *szSource = source.GetBuffer(0 );
but i need a char* and so this is not working
CString source = _T("TestString");
|
by: Oskar |
last post by:
Hi.
I`m new in cpp and i have a litlle problem.
i have a CString from Edit Box (eg."aaa bbb ccc 7327373 d feaf 323 dvjiv
234") and i want to put the data (space separated) into an array.It shuld be
somethign like this.
array1="aaa";
array1="bbb";
....
array1="234";
|
by: The Beast |
last post by:
I'm trying to create a thread to write to the serial port and I keep
getting an odd error
cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned
long (__stdcall *)(void *)'
and it points to the CreateThread call. Here is my class, why is it
doing this and how can I fix it?
<TxdRxd.h>
|
by: nsyforce |
last post by:
What is the correct way to convert a const char* to a CString? I'm
somewhat of a newbie and have tried several ways. While they all
convert ok, I'm using a profiler that shows a memory leak for every
option. Here's what I have tried:
const char* test;
test = getMyChar();
//CString myCString((LPCTSTR)test);
//CString myCString(test);
CString myCString = new CString(test);
| |
by: huguogang |
last post by:
Just curious, any one know what the 3 part parameter "class CString
filename" would mean.
The code:
int TestFunc(class CString filename)
{
fopen(filename, "w");
}
Compile using Visaul C++, there is no complain about the defintion. But
|
by: Susan Rice |
last post by:
I'm new to using CString. Why won't the following compile?
I'm using Microsoft Visual C++ 6.0
Line 37 which it complains about is the function:
37 CString ConvertFile(char *szFileName)
I tried throwing in a bunch of #includes but didn't help.
Here's the compiler errors:
Compiling...
|
by: flyingxu |
last post by:
Hi,
I run into a cstring related link problem in VC7.
My solution has 3 projects, one MFC exe, two MFC extersion DLL.
the two MFC extersion DLL export functions which use CString as
parameters.
Everything is fine in VC6.
Now I want to upgrade the solution to VC7, but I got lots of link error
like this,
/*
WinGPC5.obj : error LNK2019: unresolved external symbol "public: static
|
by: Tim Kelley |
last post by:
I am new to Visual C++ and I am having difficulty parsing a string. We have
a database that has a text field that contains multiple lines (seperated by
a carriage return and new line characters). I retrieve the field into a
CString type variable (just because that is what is used elsewhere in the
program). I need to parse out the lines of the data into 2 or 3 seperate
variables. Am I using the correct data type? If so, what functions...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |