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

Error with C program that is meant to print out path to a given file

I am having trouble with my C program that is meant to print out the path to a given file from the root. Examples: ./pathto /users/cs/a1066199/ ./pathto . /users/cs/a1066199/ ./pathto file.txt /users/cs/a1066199/file.txt ./pathto…
-1
votes
3 answers

C-string memory allocation, table of C-strings

I want to make dynamically allocated c-string table, but I think i don't understand the topic very well, could You explain it to me or correct my code? #include int main() { int i; char** t; …
-1
votes
2 answers

MFC, How do I check the CString format is match the IP Format

MFC, How do I check the CString format is match the IP Format, For example User input 192.168,1,1 Error format 256.256.2.2 Error format 192.168.2 Error format Some tip tell for me, thx
user1753112
  • 203
  • 2
  • 17
-1
votes
1 answer

LNK2001: unresolved external symbol "public: virtual long __stdcall CTProcessus::Init

How do I to fix this error, please? Error: LNK2001: unresolved external symbol "public: virtual long __stdcall CTProcessus::Init(class ATL::CStringT > >,wchar_t *,wchar_t *,wchar_t *)" Code: STDMETHODIMP CTProcessus::Init(BSTR…
user3477233
  • 37
  • 1
  • 5
-1
votes
2 answers

How do you parse a c-string?

Hi I'm trying to take a c-string from a user, input it into a queue, parse the data with a single space depending on its contents, and output the kind of data it is (int, float, word NOT string). E.g. Bobby Joe is 12 in 3.5 months \n Word:…
user3062299
  • 55
  • 2
  • 5
  • 10
-1
votes
5 answers

Remove character from array where spaces and punctuation marks are found

In my program, I am checking whole cstring, if any spaces or punctuation marks are found, just add empty character to that location but the complilor is giving me an error: empty character constant. Please help me out, in my loop i am checking like…
user3215228
  • 313
  • 1
  • 3
  • 13
-1
votes
2 answers

Copy string function not working in C

Ok, I have a function to check if a number is a palindrome (it is not completed yet) which calls a function called copystring(). If I have putchar(*destination) Within the copystring() function loop, it outputs the destination string as it…
Dylan
  • 159
  • 5
-1
votes
4 answers

Counting words in a c string

I need help completing this function so that it correctly returns the the number of words in the c-string. Maybe my logic is wrong ? #include #include #include int countwords(char *, int); using namespace std; int…
Amber Roxanna
  • 1,665
  • 4
  • 24
  • 30
-1
votes
1 answer

There is MFC project. I need to make it independent of MFC. I need a clone of CString

There is the project using MFC CString. I want to make it independent of MFC. Is there independent CString class with same methods?
Ufx
  • 2,595
  • 12
  • 44
  • 83
-1
votes
1 answer

How to make each input in an int cstring a single digit?

What I need to do, is input an int c string from the keyboard, but each digit should be a single digit int. For example in the running program if I would input "1234", it shouldn't read '1234', but a '1' followed by a '2', '3' and then '4'. I would…
-1
votes
2 answers

c++ dynamic array problems

dynamic arrays are known for letting you store a string or any data type without having to declare it size the problem that i'm facing with my c++ is the following : #include #include using namespace std; int…
-1
votes
2 answers

How to split word from CString?

I have a first case: CString stVal = " dsc | resource.c |* "; in Second case: CString stVal = " resource.c |MS"; I want only file name in both case. Please note that I am using visual studio 6.0. have you any idea? Thanks in Advance.
user2499879
  • 673
  • 3
  • 10
  • 16
-1
votes
3 answers

How does this loop end?

code example like this: #include void main() { char *s={"abcd"}; do { printf("%d\n",++s); } while(*s); } Where does the pointer s point when the loop do ends?How does it work?
Z-Cao
  • 9
  • 1
-1
votes
3 answers

Getting weird number when trying to read a number from file

I'm trying to read a number from a text file, and I'm not allowed to use a binary file. I've tried two methods to do this, and both return a strange result. The first method: char *theNumber; int i = 0; while(data>>text) { …
SemicolonExpected
  • 614
  • 2
  • 12
  • 37
-1
votes
3 answers

C-string size including null terminater

char* str = “ABC\n”; When asked "How many characters are allocated for this string?" why is the answer 5?
Arch1tect
  • 4,128
  • 10
  • 48
  • 69