Thanks. Yeah, I meant
f(Y, A, sz);
Can you actually allocate space for Y through the call to f(), though? Y is initialized in main() but no space is allocated before f() is called. Does the...
Type: Posts; User: slippy
Thanks. Yeah, I meant
f(Y, A, sz);
Can you actually allocate space for Y through the call to f(), though? Y is initialized in main() but no space is allocated before f() is called. Does the...
File allocate.c:
void f(double **X, int *A, size_t sz) {
/* ... */
X = malloc (sz * sizeof(double *));
Suppose a function f takes pointer to pointer to double A. B is a variable of the same type (declared in main() ). How do you (i) allocate space to A in f() and (ii) modify the contents of B via f()?...
Is there a way to get a function to know about the size of an array passed to it without explicitly passing its size?
type f(type *a, size_t sz) { /* ... */}
type f(type *a) { /*...
Suppose S is a structure:
typedef struct {
type s1;
type s2;
// ...
type sn;
} S;
Thanks. I changed the following lines
inline void endian_swap(unsigned int& x) {
// ...
unsigned int * v = new unsigned int[1];
//...
GCA.read(reinterpret_cast<char*>(v), sizeof(unsigned...
I'm trying to swap endianness in a big-endian file: my platform is little-endian, and so things are coming out wierd:
#include <iostream>
#include <fstream>
using namespace std;
//...
Thanks!
I already have the software (and the domain), but have no idea about where to put everything. We're getting a new machine soon, and I was wondering if that could act as the server (see...
What kind of resources do you need to start your own online forum? I tried godaddy.com and thought about purchasing enough storage space for ~1000 email accounts, but I'm not sure if this the most...
Is this a good way to use a namespace?
#include <iostream>
namespace Hw { void hello(); }
void Hw::hello() { using namespace std; cout << "Hello, world.\n"; }
int main() { Hw::hello();}
Thanks, Codeplug. The function works now, but it's very sloppy, and the goal is efficiency (which is why numeric containers were used in the first place). Would inlining or recursion be reasonable...
`cake' represents a 5-by-5 matrix. How would you do a row-wise addition on `cake'? I tried slicing `cake' and adding the slices, but things like state = cake[l1] + ... + cake[l5];
are illegal, and...
Thanks!
Thanks for your help!
I traced the problem to the way values are assigned to an array in a structure:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
But doesn't ra++ move the pointer up by sizeof(int)? I thought &ra[0] points to the zeroth element (always), and ra is the current position. Does ra++ move &ra[0] up too? Why?
Why does the address &ra[0] keep changing?
void overlappingPermutations(Distribution& D, int* ra) {
// overlappingPermutations
//
// Take five consecutively-generated RNs at...
What about just generating messages that are grammatically correct? A combination like
"97xj34m725"
probably wouldn't occur in a plaintext message....
Also:
If the key is shorter than...
(See Stroustrup, The C++ Programming Language (3rd ed.), p. 164).
How would you help decrypt messages encrypted using the OTP algorithm?
I'm able to encrypt messages alright using XOR:
...
Thanks!
I played around with two different gap sequences (Sedgewick, Pratt) , but didn't bother to generate enough randoms to see an appreciable difference in each.
int[] sedge = {1391376,...
Thanks all! It works, and the code is much cleaner.
Now I have to go backward( ) ; )
Thanks, but I still have the same problem : (
The ciphertext is almost identical to the message:
#include <iostream>
#include <string>
using namespace std;
#define DEBUG
Here's a complete implementation taken (verbatim) from Stroustrup (The C++ Programming Language, 3rd ed., p. 158; comments added).
`cmp' is a comparison function (defined elsewhere).
How would...
Oh.
Thanks! It's working fine now.
Oops, sorry.
The "such a pointer" is
"a pointer to a function taking arguments of type pointer to character and reference to integer and returning no value"
which is a