Questions tagged [cstring]

Refers to 0-terminated strings as popularized by C, as well as the header-files `string.h` and `cstring`.

A C string is a sequence of non-zero bytes terminated by a NUL byte (0x00), usually used to store ASCII or UTF-8 text.

C strings are defined as char arrays in C and C++, where char is an 8-bit type. C strings can be referred to using a char pointer.

Extensions to the basic C string (e.g. to 16-bit wchar_t "wide strings") also exist in various programming environments.

In C++, the standard std::string class interoperates with C strings via the .c_str() method, though beware that std::strings can contain embedded 0-bytes.

488 questions
-1
votes
1 answer

set containing a class with CString member variables stores only first letters

I am working with MFC and I have this class: class CUnit { private: CString name; CString init; CString chp; CString rhp; CString condition; public: CUnit(void); ~CUnit(void); void setName( CString str ); void…
-1
votes
2 answers

Conversion of CString to float

Some body help me regarding to the following problem strFixFactorSide = _T("0.5"); dFixFactorSide = atof((const char *)(LPCTSTR)strFixFactorSide); "dFixFactorSide" takes value as 0.0000; How I will get correct value?
Vaibhav
  • 69
  • 1
  • 2
  • 4
-1
votes
1 answer

Exception error in CStringData GetData() in MFC

In my function, Im assignning one Global CString to varaible declared in header file.But it shows unhandled exception error. My code CString sReceiceStr = _T(""); //Global variable void CChatServerDlg::AddMsg( userinfo *udata, CString…
Anu
  • 905
  • 4
  • 23
  • 54
-2
votes
1 answer

Should these two cstrings of different sizes be returning 0(equal) with strcmp?

I have two classes that will create a dynamically allocated cstring (null terminated) of n size upon an object of that class being created. In one class, I have a member function overloading the equivalency operator, and in the other class, I have a…
Victor
  • 57
  • 2
  • 8
-2
votes
1 answer

Strange behaviour or may be bug in sprintf() in c++

I just found strange thing about sprintf() (c++ library function). have a look at these two solutions Time limit Exceeded solution Accepted Solution the only difference between them is that, I used sprintf(a,"%d%c",n,'\0'); in TLE solution, in AC…
hkbharath
  • 317
  • 7
  • 15
-2
votes
3 answers

Remove Specific Line From CString C++

How to remove a specific line from a CString? This line contain: "Line to remove". For example, the input is: Remove Specific'\n' Line to remove'\n' Line From '\n' CString C++. The output should be: Remove Specific'\n' Line From '\n' CString C++.
-2
votes
3 answers

How do I pass this array of c strings correctly?

I have my array of C-Strings declared as: char *argv[MAXARGS]; MAXARGS basically just tells us how many c strings are in the array for indexing purposes. I want to pass it to this function below... int builtin_cmd(char **argv) but nothing seems to…
user3040019
  • 51
  • 2
  • 10
-2
votes
1 answer

cString is Deprecated?

I don't know where to turn to figure this out so I'm turning to you guys, the BEST! I'm new to objective c. I get the deprecated warning with the following line of code. Any ideas on how to make this compatible with iOS 6? const char *pUrl =…
-2
votes
2 answers

Can anyone help me find the bug in this C function?

So, I have written a mystrstr() function which should behave exactly as the original strstr() function. I have tested huge amount of cases and my function seems to work. However, it does not pass some of the tests of the online submission…
Azad Salahli
  • 876
  • 3
  • 14
  • 30
-2
votes
2 answers

scanf and char pointers in C -- unexpected output

void main(int argc, char * argv[]) { FILE* inFile = NULL; char * bufferFromStdin; char buf[100]; printf("Enter something:\n"); scanf("%s", buf); printf("First scan from stdin is: %s\n", buf); if(buf == "THIS" || buf[0]=='T') { …
user884685
  • 47
  • 2
  • 4
  • 8
-3
votes
2 answers

How to add two pointers?

How to add parameterB and pictureName? I got an error that says: '+': cannot add two pointers. CString parameterA = _T("\"") + mycustompath + _T("identify.exe\""); CString parameterB = _T(" -format \"%w\" ") + _T("\"") + mycustompath; …
karikari
  • 6,627
  • 16
  • 64
  • 79
-3
votes
1 answer

Upgrading ASCII Password Cracker to Multiple Characters

I have recently started learning C++, and I have decided to create a basic password-cracking console program. In it, the user inputs a character, and the program tries to guess what character the user entered by starting at the 32nd ASCII character…
-3
votes
4 answers

String vs C-string in declaring a member variable

I have a member function in a class that returns a String. What do I need to do in the declaration if I want to make the return a C-string type? The revised function may or may not have a C-string argument(It is OK to remain the current…
jsh6303
  • 2,010
  • 3
  • 24
  • 50
-3
votes
2 answers

How to reverse a character array in c++?

Our teacher wants us to write a program that reverses the order of a character array. So like if the user inputs "hello", the program will output "olleh". Here's the function that we were given: void reverse_string(char coolstring[11], char…
user2225875
  • 1
  • 1
  • 1
-3
votes
1 answer

why is this value being set to 0? O_O

chMB() is a define to MessageBoxA( 0, text, "title", MB_OK );so it displays the text and I can see results. My problem is with the following codez: CString szWow; szWow.Format( "%u", idCandidate ); chMB( szWow ); const __int64 i64set =…
Vinícius
  • 15,498
  • 3
  • 29
  • 53
1 2 3
32
33