string.h Questions
6
Solved
What is the reason for strlcpy.c to copy the arguments into local variables:
size_t
strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
/* Co...
6
Solved
#include<string.h>
#include<stdio.h>
void main()
{
char *str1="hello";
char *str2="world";
strcat(str2,str1);
printf("%s",str2);
}
If I run this program, I'm getting run time prog...
1
Solved
The C standard library string.h contains several functions to manipulate strings, all of which start with str and end with an abbreviation. Some of these abbreviations are obvious:
strlen string ...
Llewellyn asked 4/3, 2017 at 2:48
2
Solved
char s1[] = "0";
char s2[] = "9";
printf("%d\n", strcmp(s1, s2)); // Prints -9
printf("%d\n", strcmp("0", "9")); // Prints -1
Why do strcmp returns different values when it receives the sam...
Juggler asked 12/10, 2015 at 22:40
3
Solved
I was looking for this on internet and in every place with the functions of string.h these two are not mentioned.
Is because what? They aren't in every compiler?
3
Solved
What is the significant difference between memcpy() and strncpy()? I ask this because we can easily alter strncpy() to copy any type of data we want, not just characters, simply by casting the firs...
6
Solved
Which is the best way to include the standard header string.h in a C++ project?
Using the [dot]h at the end, like this:
#include <string.h>
or just writing
#include <string>
Or, m...
1
I want to optimize some code such that all the functions in string.h will be inlined. I'm on x86_64.
I've tried -O3, -minline-all-stringops and when I do "nm a.out" it shows it is calling the glib...
1
© 2022 - 2024 — McMap. All rights reserved.