Thank you very much for your time laserlight :)
Type: Posts; User: Mr.Lnx
Thank you very much for your time laserlight :)
Ok.So we have 8 * 8 = 64bits hence 2 storage units of 32. The layout would be :
|__4 bits for a member___|___28bits padding___| |___8bits for member b____|__24bits...
So the unnamed 0-bit member does not occupy any memory ok.
Yes I meant that each unsigned int occupies 4 bytes in the memory so the result of sizeof(my_s) I expected instead of 12 bytes not 8 that is why I think I have no understand the concept of bit...
#include <stdio.h>
typedef struct s {
unsigned int a: 4;
unsigned int: 0;
unsigned int b: 8;
} my_s;
int main(void) {
printf("%d , %d" , sizeof(unsigned int) , sizeof(my_s));
Hello to all. There is a point that I can't understand.
struct s {
unsigned int a: 4;
unsigned int: 0;
unsigned int b: 8;
}
I mean it doesn't open the file at the task manager.
I used Nominal Animal code too I didn't see the difference only the message that is opened succesfully.
Hello to all. I have Geany IDE and gcc compiler. I have the following code :
#include<stdio.h>
#include<stdlib.h>
#define FILE_NAME "/home/kostas/PROGRAMS/simple"
int main(void)
@Nominal ok we have a structure with members (one integer and seven characters) that have 11 byte size (assuming that int is 4 and each character 1 byte) so 16byte size and 8byte alignment. (5 bytes...
As the program begins. There is no something that you call "metadata" for dynamically allocated chunk 1 at the beginning because malloc hasn't called yet.
@Nominal Thank you for the big explanation. I have some queries though
I don't understand what is [ C library metadata for dynamically allocated chunk n ] for example is only a label for your...
@Nominal Animal
the correct version of read_line function I think is :
int read_line(char str[] , int n)
{
int ch , i =0 ;
while( (ch= getchar()) !='\n' && i<n)
Hello to all.
I have this code :
/*********************************************************
* From C PROGRAMMING: A MODERN APPROACH, Second Edition *
* By K. N. King ...
Hmm ok. I got it. With the restrict keyword we don't want two pointers point to the same thing. Pointing to the same thing is always a possibly situation for overlapping.We should use memmove instead...
First of all you need to read the string from the user. So you want a function for it. I suggest you using fgets function.
fgets - C++ Reference
After all you need to make your process in your...
Sorry but how is from one pointer? s[i] is also a pointer right? the function treats it as a pointer on its body like we know. And d[i] is also a pointer in the function only! So we copy from s[i] to...
I mean that is canceled. When you say that you declare a pointer to be restricted how you can have access from some other? live the previous examples. The only access is from one pointer.
For...
Ok but with this the concept of restriction of a pointer does not corrupted?
The behavior if you have an access to a pointer that have been declared as restricted does not undefined?
And why my book writes :
"A pointer that is been declared using restrict is called restricted pointer.The intent is that if p points to an object that is later modified ,then that object is not...
I have a query about memcpy's prototype.
Since the arguments are restricted pointers and according to a restricted pointer only that pointer has access to the object how the function works? and...
I have a query about memcpy's prototype.
Since the arguments are restricted pointers and according to a restricted pointer only that pointer has access to the object how the function works? and...
int calsum(int x, int y , int z); is only a declaration of the funtion in order to help the compiler to check the call later.
The values goes to the call. After the call the value of the function...
#include <stdio.h>
int calsum (int x, int y, int z);
int main(void)
{
int a, b, c;
printf ("Enter any three numbers");
scanf ("%d %d %d", &a, &b, &c);
printf ("Sum = %d\n", calsum(x,y,z));
@laserlight yes you are right. I changed my first post.
First of all you need an array of strings. So this is easy with an array of pointers for example :
char *planets[] = { "Mercury" , "Venus" , "Earth" , "Mars" , "Jupiter" , "Saturn" , "Uranus"...