Linked Questions

0 votes
3 answers
5k views

I remember reading the explanation on the use of this line of code, but I've read so many books on sockets for the past week that I can't find it anymore. I do remember in the book, they wrote their ...
user2644360's user avatar
0 votes
3 answers
481 views

char *pt = "hello"; std::string str = "hello"; Does str also end with '/0' (is null terminated)?
jiafu's user avatar
  • 6,596
0 votes
2 answers
779 views

There is a saying when we declare char variable. We should declare like this -> char ArrayName[Maximum_C-String_Size+1]; For example: char arr[4+1] = {'a', 'b', 'c', 'd'} but arr[4] = {'a', 'b', '...
黃翊唐's user avatar
  • 135
0 votes
5 answers
493 views

#include <stdio.h> #include <string.h> int main() { char ch[20] = {'h','i'}; int k=strlen(ch); printf("%d",k); return 0; } The output is 2. As far as I ...
Vaibhav Verma's user avatar
0 votes
2 answers
115 views

I was solving a problem on codeforces, but I keep running into unwanted garbage values as output. What can I do? #include <iostream> #include <string> #include <conio.h> #include <...
Rifaqat Islam's user avatar
0 votes
0 answers
136 views

Can you say me why different size in this example: // 1 std::string str = "Sun Mar 29 16:05:28 2020"; const unsigned char *t{}; t = (unsigned char *) str.c_str(); std::cout << "t: " << t ...
mat.twg's user avatar
  • 775
0 votes
0 answers
37 views

I found below shown piece of code on libcurl website, but I don't get the reason of setting first char to 0 errbuf[0] = 0; ? What about the others? curl = curl_easy_init(); if(curl) { CURLcode res; ...
Anees's user avatar
  • 87
24 votes
9 answers
12k views

Just wondering why this is the case. I'm eager to know more about low level languages, and I'm only into the basics of C and this is already confusing me. Do languages like PHP automatically null ...
alex's user avatar
  • 492k
2 votes
5 answers
542 views

I've noticed a weird discrepancy in C++. Say I have this code: const char myChars[] = "12345"; std::cout << myChars; The output is: 12345 However, if I then change it to: const char myChars[]...
Kyle's user avatar
  • 4,034
8 votes
8 answers
1k views

I am trying to improve my understanding of C++, pointer arithmetic especially. I use atoi pretty often, but I have rarely given thought as to how it works. Looking up how it is done, I understand it ...
Joshua's user avatar
  • 4,330
1 vote
3 answers
2k views

I was looking for some c++ code, and was confused by if(ptr && *ptr), what does it do in this case? // Process the data here. We just break the data into separate pieces and // display it ...
Brandon's user avatar
  • 21
1 vote
1 answer
3k views

This may sounds little odd or question may be a trivial one, but for most of my life I was programming in PHP (yeah, I know how it sounds). So when I switched to C++ there are things quite unfamilliar ...
user3038744's user avatar
0 votes
2 answers
3k views

I'm writing a code to encrypt the entered text in Caesar Cipher but I'm getting a problem. While running my code my loop is not being terminated at null character. Code is as follows: #include <...
Aiman Muzafar's user avatar
2 votes
5 answers
633 views

I have a char[4] dataLabel that when I say wav.read(dataLabel, sizeof(dataLabel));//Read data label cout << "Data label:" <<dataLabel << "\n"; I get the output Data label:data� ...
Matt's user avatar
  • 127
0 votes
1 answer
1k views

I was simply using copy function in c++ for copying a string into an array. But the result shown for the following code contain garbage values: #include <iostream> #include <string> using ...
Chinmay Vemuri's user avatar

15 30 50 per page