-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Question 1
I have a struct like,
struct foo
{
int a;
char c;
};
When I say sizeof(foo), i am getting 8 on my machine. As per my understanding, 4 bytes for int, 1 byte for char and 3 bytes for padding. Is that correct? Given a struct like the above, how will I find out how many bytes will…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
#include <iostream>
using namespace std;
int main()
{
cout << "Do you need to encrypt or decrypt?" << endl;
string message;
getline(cin, message);
int letter2number;
for (int place = 1; place < sizeof(message); place++)
{
letter2number = static_cast<int>(message[place]);
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
When declaring a const table, it is possible to get the size of the table using sizeof. However,
once you stop using the symbol name, it does not work anymore. is there a way to have the following program output the correct size for table A, instead of 0 ?
#include <stdio.h>
struct mystruct…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
This question already has an answer here:
When is an array name or a function name 'converted' into a pointer ? (in C)
4 answers
I just made a test program after reading the…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I am having a hard time in manipulating strings while writing module for linux. My problem is that I have a int Array[10] with different values in it. I need to produce a string to be able send to the buffer in my_read procedure. If my array is {0,1,112,20,4,0,0,0,0,0}
then my output should be:
0:(0)
1:-(1)
2:-------------------------------------------------------------------------------------------------------(112)
3:--------------------(20)
4:----(4)
5:(0)
6:(0)
7:(0)
8:(0)
9:(0)
when…
>>> More