大约有 43,000 项符合查询结果(耗时:0.0327秒) [XML]
How to send a simple string between two programs using pipes?
...lt;sys/types.h>
#include <unistd.h>
int main()
{
int fd;
char * myfifo = "/tmp/myfifo";
/* create the FIFO (named pipe) */
mkfifo(myfifo, 0666);
/* write "Hi" to the FIFO */
fd = open(myfifo, O_WRONLY);
write(fd, "Hi", sizeof("Hi"));
close(fd);
/* rem...
Why is argc not a constant?
...at any C function can do. Also, getopt is declared as int getopt(int argc, char * const argv[], const char *optstring);. And here the const is not top level, but declares the pointers to be const, a promise to not modify them (although the strings that they point to might conceivably be modified).
...
How to parse the AndroidManifest.xml file inside an .apk package
...// StringTable, each string is represented with a 16 bit little endian
// character count, followed by that number of 16 bit (LE) (Unicode) chars.
int stOff = sitOff + numbStrings*4; // StringTable follows StrIndexTable
// XMLTags, The XML tag tree starts after some unknown content after the
// S...
What differences, if any, between C++03 and C++11 can be detected at run-time?
...zeof(b);
}
Also, the fact that string literals do not anymore convert to char*
bool isCpp0xImpl(...) { return true; }
bool isCpp0xImpl(char*) { return false; }
bool isCpp0x() { return isCpp0xImpl(""); }
I don't know how likely you are to have this working on a real implementation though. One t...
What is the difference between printf() and puts() in C?
...e (except for the added newline) if the string doesn't contain any control characters (%) but if you cannot rely on that (if mystr is a variable instead of a literal) you should not use it.
So, it's generally dangerous -and conceptually wrong- to pass a dynamic string as single argument of printf...
Best way to repeat a character in C#
...turns
"aa"
from...
Is there a built-in function to repeat string or char in .net?
share
|
improve this answer
|
follow
|
...
Detecting endianness programmatically in a C++ program
... for !
bool is_big_endian(void)
{
union {
uint32_t i;
char c[4];
} bint = {0x01020304};
return bint.c[0] == 1;
}
The principle is equivalent to the type case as suggested by others, but this is clearer - and according to C99, is guaranteed to be correct. gcc prefers ...
Does the C++ standard mandate poor performance for iostreams, or am I just dealing with a poor imple
...ith GCC gives the following breakdown:
44.23% in std::basic_streambuf<char>::xsputn(char const*, int)
34.62% in std::ostream::write(char const*, int)
12.50% in main
6.73% in std::ostream::sentry::sentry(std::ostream&)
0.96% in std::string::_M_replace_safe(unsigned int, unsigned int, char...
C++ SFINAE examples?
...here):
template<typename T>
class IsClassT {
private:
typedef char One;
typedef struct { char a[2]; } Two;
template<typename C> static One test(int C::*);
// Will be chosen if T is anything except a class.
template<typename C> static Two test(...);
public:
...
How do you determine the size of a file in C?
...include <sys/stat.h>
#include <sys/types.h>
off_t fsize(const char *filename) {
struct stat st;
if (stat(filename, &st) == 0)
return st.st_size;
return -1;
}
Changes:
Made the filename argument a const char.
Corrected the struct stat definition, which was...