Thread: Does std::string supports wide characters?
Started 1 month ago by bajajv
Hello,
I am trying to implement the CString class. I can implement the functions using the standard namespace string class, but not sure whether it will support the wide characters or not.
Also, please suggest that how can I check for characters of other languages? Can I get characters of other languages by changing the language settings of my machine?
Is there a way to declare a string where inside the string, a predefined label is included? I.e.,
#define MY_CODE 0x1000
char str[]="Here is MY_CODE"; //will not work I know
Any way to get around this instead of hard-coding it?
Jos,
Thanks for the quick reply. However, although it works, can you explain to me how it works in preprocessor? Intuitively I thought the above 2 defines is equivalent to sth like this
#define concat(a,b) a###b
Of course the above didn't work.
مرحبا
اسمي ملكة جمال jesical ، رأيت بروفايلك اليوم ، وبعد ذلك تمر ، ط ملء المزيد من الاهتمام للاتصال بك ، وأنا مثلك من فضلك أرسل لي رسالة بالبريد الالكتروني على عنوان بريدي الالكتروني الخاص
عبر (jesicalbaby61@yahoo.com.hk) بالنسبة لي أن أرسل إليكم لبلدان جزر المحيط الهادئ ، واقول لكم المزيد عني. ثم من هنا يمكننا أن نتحرك on.I سيكون في انتظار ردكم على رسالتي above.thanks عنوان البريد الإلكتروني...
مرحبا
اسمي ملكة جمال jesical ، رأيت بروفايلك اليوم ، وبعد ذلك تمر ، ط ملء المزيد من الاهتمام للاتصال بك ، وأنا مثلك من فضلك أرسل لي رسالة بالبريد الالكتروني على عنوان بريدي الالكتروني الخاص
عبر (jesicalbaby61@yahoo.com.hk) بالنسبة لي أن أرسل إليكم لبلدان جزر المحيط الهادئ ، واقول لكم المزيد عني. ثم من هنا يمكننا أن نتحرك on.I سيكون في انتظار ردكم على رسالتي above.thanks عنوان البريد الإلكتروني...
Quote:
Originally Posted by saravanan82 Hi All,
I tried to execute follwoing program, which got killed by the OS.
#include<stdlib.h>
main()
{
while(1) { char *c=(char*)malloc(10000); }
}
I got one message stating "Killed" in the command prompt.
Pls, any one can explain me why it got killed by the OS.
Note:
OS: Linux
Compiler: g++...
Quote:
Originally Posted by onkardesai can i get a C code to read a number until -1 is entered ..and then print each number per line What have you done yourself already? We are not going to do your homework for you because we would learn even more (if it were new to us) and you wouldn't learn anything at all. You don't want that do you?
kind regards,
Jos
firstly i hv done my BE ..hm work and all is over for me in school days ..i dont want the exact code or sumthin ..i dont even expect tht ..i jst want to know the logic .i guess we can solve this by malloc and realloc ..can u suggest me sum different method ..jst give me logic ..i ll post my code
Quote:
Originally Posted by onkardesai firstly i hv done my BE ..hm work and all is over for me in school days ..i dont want the exact code or sumthin ..i dont even expect tht ..i jst want to know the logic .i guess we can solve this by malloc and realloc ..can u suggest me sum different method ..jst give me logic ..i ll post my code You're programming in C so ...
While specifying path try "/" rather than "\".
Ex: If your file is in C:
Type c:/something.txt Quote:
Originally Posted by Banfa If you are getting NULL returned it is because the program was unable to open the file.
This could be because You have the name of thje file wrong in the function call You have the path to the file wrong in the function call...
The address of a[0] and a are not stored anywhere, they are a property of a[0] and a. The address of a[0] and the address of a are the same because a[0] is the first element in a. Think of a row of cars parked nose to tail. The start of the row of cars and the start of the first car in the row are at the same place. That place is not stored anywhere because there is no place for storing places on the street, there is only places for storing cars.
when I build my final executable using shared libs, I just replaced static with shared in makefile, also I have .a files availbale for static and .so files available for shared. I did small test, when I remove one library linking for static, I got many undef symbols, final exe file didn't built, the same test I did for shared, everytime execubale builts no matter whether I have all shared lib linking with -l option or not, looklike final...
Quote: You can not work out the size of allocated data from y alone, you need n too ...... size = sizeof(int) * n; That's the problem with using C/C++ arrays. If you want to avoid overflowing or out of bounds elements in the array, you must keep track of the size (i.e. the n value). If this sort of thing seems laborious and dangerous, try the STL vector. It deals with those issues.
Quote: Originally Posted by banfa Examine the code more closely, it is not a pointer that is being passed but a structure. You are quite right. I missed the asterix (*) that dereferenced px. Definitely undefined behavior.
Hi, I want to implement the cstring class using wstring. but in assignement operator, I need to know how to add null while assigning some wchar_t type of data to the wstring. below is my code - class CString { public: wstring wStr; CString () {wStr = L"";} CString (wstring str) {wStr = str;} CString& operator =( const CString& stringSrc ); CString& operator =( wchar_t wcChar ); }; int main() { CString...
when I debug it was asking for an exe to debug with I chose the one it allowed me to without typing but that doesn't work. How do I change it now ? second unless I have a code back to the header how am I going to test the code ? so do I connect it to the exe that I've now made then change the code to point towards the header and act on the codes ?
I hesitate to take this further after the comprehensive treatment above as am no expert however here is a coded example from my book "Programming with C++" by John R Hubbard pp 331 Expand | Select | Wrap | Line Numbers #include<iostream> #include<vector> using namespace std; typedef vector<double>Vec;...
Unknow characters are inserted into my std::string... Unknow characters are inserted into my std::string automatically, even when
I do a std::string.clear(), and this happens only in Release and never in
Debug mode!
Std::string の length() は、strlen... Std::string の length() は、strlen と厳密には == じゃない ? string は、途中に '\0' を含むことができるから。
...
about 11 hours ago from web
At what point in a C++ developer's career do they... At what point in a C++ developer's career do they actually learn when to use std::stringstream over std::string and tons of += calls? 4:45 PM Oct 2nd, 2007 from twitterrific
Thread profile page for "Does std::string supports wide characters?" on http://bytes.com.
This report page is a snippet summary view from a single thread "Does std::string supports wide characters?", located on the Message Board at http://bytes.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity