473,377 Members | 1,153 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,377 software developers and data experts.

how do i use a 'string' like c#


string word = "cool";
in c#

how do i do that in c++

i searched online and i was lost.....
Jun 25 '06 #1
6 1488
Hareth wrote:
string word = "cool";
in c#

how do i do that in c++


I't s amuch more complex issue in C++ because there are many different kinds
of strings:

// C++ standard library
#include <string>
using namespace std;

string word = "cool";
// "ASCII-Z string
const char* word = "cool";
// MFC CString
CString word = "cool";

// .NET String (compile with /clr)
#import <System.Dll>
using namespace System;

String word = "cool";

.... etc.

What do you want to do with the string? Are you writing .NET code, or
native (unmanaged) code?

-cd

Jun 25 '06 #2

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
i was planning to write a .net code....

thanks for yor help btw

i was thinking of using ur example

// C++ standard library
#include <string>
using namespace std;
or
// .NET String (compile with /clr)
#import <System.Dll>
using namespace System;


Jun 25 '06 #3

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
Hareth wrote:
string word = "cool";


I believe you forgot a ^ managed pointer symbol :)

String ^word = "cool";

And not to forget, my favorate string datatype, because (personally) I only
work with C++ in a COM environment, the CComBSTR

so
CComBSTR word(L"cool");
or
CComBSTR word;
word = L"cool";

(since I modified the CComBSTR class, It has the same manipulation
capabilities as CString);

and there also is a Widestring variant (because Ascii is ooold);
PWSTR word = L"cool";

Jun 25 '06 #4

"Egbert Nierop (MVP for IIS)" <eg***********@nospam.invalid> a écrit dans le
message de news: %2****************@TK2MSFTNGP05.phx.gbl...

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
Hareth wrote:
string word = "cool";


I believe you forgot a ^ managed pointer symbol :)

String ^word = "cool";


No. He spoke about native std::string, not about managed System::String
(mark the case difference).

Arnaud
MVP - VC
Jun 25 '06 #5

"Arnaud Debaene" <ad******@club-internet.fr> wrote in message
news:uZ**************@TK2MSFTNGP04.phx.gbl...

"Egbert Nierop (MVP for IIS)" <eg***********@nospam.invalid> a écrit dans
le message de news: %2****************@TK2MSFTNGP05.phx.gbl...

"Carl Daniel [VC++ MVP]"
<cp*****************************@mvps.org.nospam >
wrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
Hareth wrote:
string word = "cool";


I believe you forgot a ^ managed pointer symbol :)

String ^word = "cool";


No. He spoke about native std::string, not about managed System::String
(mark the case difference).

Arnaud
MVP - VC


gee, you're right. That also exists... :)

Jun 25 '06 #6
Arnaud Debaene wrote:
"Egbert Nierop (MVP for IIS)" <eg***********@nospam.invalid> a écrit
dans le message de news: %2****************@TK2MSFTNGP05.phx.gbl...

"Carl Daniel [VC++ MVP]"
<cp*****************************@mvps.org.nospam > wrote in message
news:u9**************@TK2MSFTNGP04.phx.gbl...
Hareth wrote:
string word = "cool";


I believe you forgot a ^ managed pointer symbol :)

String ^word = "cool";


No. He spoke about native std::string, not about managed
System::String (mark the case difference).


.... but I did miss the ^ on my managed String.

-cd
Jun 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Krakatioison | last post by:
My sites navigation is like this: http://www.newsbackup.com/index.php?n=000000000040900000 , depending on the variable "n" (which is always a number), it will take me anywhere on the site......
5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
9
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
10
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is...
2
by: Andrew | last post by:
I have written two classes : a String Class based on the book " C++ in 21 days " and a GenericIpClass listed below : file GenericStringClass.h // Generic String class
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
2
by: Badass Scotsman | last post by:
Hello, Using VB and ASP,NET I would like to be able to search a STRING for a smaller STRING within, based on the characters which appear before and after. For example: String1 = " That was...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
8
by: drjay1627 | last post by:
hello, This is my 1st post here! *welcome drjay* Thanks! I look answering questions and getting answers to other! Now that we got that out of the way. I'm trying to read in a string and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.