Search:

Type: Posts; User: slippy

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    1,244

    Thanks. Yeah, I meant f(Y, A, sz); Can...

    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...
  2. Replies
    4
    Views
    1,244

    Dynamic allocation inside function

    File allocate.c:



    void f(double **X, int *A, size_t sz) {

    /* ... */

    X = malloc (sz * sizeof(double *));
  3. Replies
    2
    Views
    793

    Pointer to pointer

    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()?...
  4. Replies
    2
    Views
    1,019

    Size of array in function

    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) { /*...
  5. Replies
    9
    Views
    1,301

    Cycling through structure

    Suppose S is a structure:


    typedef struct {

    type s1;
    type s2;
    // ...
    type sn;
    } S;
  6. Replies
    9
    Views
    9,423

    Thanks. I changed the following lines inline...

    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...
  7. Replies
    9
    Views
    9,423

    Changing endianness

    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;

    //...
  8. Replies
    5
    Views
    1,579

    Thanks! I already have the software (and the...

    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...
  9. Replies
    5
    Views
    1,579

    Starting an online forum

    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...
  10. Replies
    1
    Views
    957

    Help with namespaces

    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();}
  11. Replies
    3
    Views
    1,125

    Thanks, Codeplug. The function works now, but...

    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...
  12. Replies
    3
    Views
    1,125

    Asking slice_array for elements

    `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...
  13. Replies
    8
    Views
    1,148

    Thanks!

    Thanks!
  14. Replies
    8
    Views
    1,148

    Thanks for your help! I traced the problem to...

    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>
  15. Replies
    8
    Views
    1,148

    But doesn't ra++ move the pointer up by...

    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?
  16. Replies
    8
    Views
    1,148

    Help with pointers

    Why does the address &ra[0] keep changing?




    void overlappingPermutations(Distribution& D, int* ra) {

    // overlappingPermutations
    //
    // Take five consecutively-generated RNs at...
  17. Replies
    11
    Views
    6,169

    What about just generating messages that are...

    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...
  18. Replies
    11
    Views
    6,169

    Decrypting OTP ciphertext

    (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:


    ...
  19. Thread: Shell sort

    by slippy
    Replies
    3
    Views
    3,810

    Thanks! I played around with two different gap...

    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,...
  20. Replies
    7
    Views
    1,103

    Thanks all! It works, and the code is much...

    Thanks all! It works, and the code is much cleaner.

    Now I have to go backward( ) ; )
  21. Replies
    7
    Views
    1,103

    Thanks, but I still have the same problem : (

    Thanks, but I still have the same problem : (
  22. Replies
    7
    Views
    1,103

    Help with functions

    The ciphertext is almost identical to the message:



    #include <iostream>
    #include <string>
    using namespace std;

    #define DEBUG
  23. Thread: Shell sort

    by slippy
    Replies
    3
    Views
    3,810

    Shell sort

    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...
  24. Thread: functions

    by slippy
    Replies
    4
    Views
    1,010

    Oh. Thanks! It's working fine now.

    Oh.

    Thanks! It's working fine now.
  25. Thread: functions

    by slippy
    Replies
    4
    Views
    1,010

    Oops, sorry. The "such a pointer" is "a...

    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
Results 1 to 25 of 55
Page 1 of 3 1 2 3