Search:

Type: Posts; User: browser

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. modifying for loop from map of integers to vector

    So I have a function written as follows



    inline
    tSomething::tSomething(map<int, tSomethingElse* > const & Points,
    tWhatever const * a_ptr,
    int ID,...
  2. Replies
    14
    Views
    1,480

    Sorry guys, I have spotted another mistake in the...

    Sorry guys, I have spotted another mistake in the code. The above was working fine because all the types ("X") in the the file were the same. It turns out if they are different like here;



    4...
  3. Replies
    14
    Views
    1,480

    Yes, it just needed to be read once. But I think...

    Yes, it just needed to be read once. But I think the problem was that after fscanf, fgets still went to the beginning of the file to read again. If I changed the '4' to an 'X' the fgets still printed...
  4. Replies
    14
    Views
    1,480

    So I 'fixed' it by doing this; fgets(buf,...

    So I 'fixed' it by doing this;



    fgets(buf, sizeof buf, input);
    N=atoi(buf);
    printf("N has been read as %d\n", N);
    fgets(desc, sizeof desc, input);
    printf("Description has been read...
  5. Replies
    14
    Views
    1,480

    Thanks, I changed that and my output still looks...

    Thanks, I changed that and my output still looks weird, but so far is the only one that has printed 'user description' in some form to the screen




    N has been read as 4


    Description is ...
  6. Replies
    14
    Views
    1,480

    Okay guys, I may have broken it again. Quick...

    Okay guys, I may have broken it again.

    Quick recap, I am trying to read filename.xyz



    4
    User description
    X -0.906801 0.569837 0.066005
    X 0.956585 -0.258900 0.342064
  7. Replies
    18
    Views
    2,415

    I have seen this around but have so far not been...

    I have seen this around but have so far not been able to use it
  8. Replies
    18
    Views
    2,415

    Thanks guys, I think it was the "type" that got...

    Thanks guys, I think it was the "type" that got me into trouble. I also used a function in order to read N first



    int findN(FILE* input)
    {
    int N;
    fscanf(input, "%d", &N);
    return(N);
    }
  9. Replies
    18
    Views
    2,415

    Isn't that what I am doing here; int main()...

    Isn't that what I am doing here;


    int main()
    {
    FILE* input;
    int N;
    char type;
    int i, j;
    double finalvalue;
  10. Replies
    18
    Views
    2,415

    Jim - I am using malloc after I have read the...

    Jim - I am using malloc after I have read the file...well, while I am reading the file?

    anduril - I moved


    double array[N][3];
    double *ptr;


    to above my malloc line. Still prints "N is...
  11. Replies
    18
    Views
    2,415

    So if N needs to be read from a file and the...

    So if N needs to be read from a file and the array size needs to be set to 3 x N how would I do that without getting this problem?

    Thanks
  12. Replies
    18
    Views
    2,415

    #include #include #include...

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <string.h>

    double finalcalc(double array[][3], int N);

    int main()
    {
    FILE* input;
  13. Replies
    18
    Views
    2,415

    Thanks Jim, I have fixed those. Still getting the...

    Thanks Jim, I have fixed those. Still getting the same problem.
  14. Replies
    18
    Views
    2,415

    Multidimensional array into function

    I have read a file into an array in my main and it has done so correctly (after help from this board a few threads down). I now need to perform arithmetic with that array in an external function....
  15. Replies
    14
    Views
    1,480

    Thanks guys, got it working again. I think I was...

    Thanks guys, got it working again. I think I was getting confused with the "while" part of the code and it is now working without that.

    And sorry Adak, next time I will try to post more of the...
  16. Replies
    14
    Views
    1,480

    Thanks for all the suggestions, but I am still...

    Thanks for all the suggestions, but I am still having trouble.

    I have tried



    fscanf(input, "%[^\n]", &desc);


    and
  17. Replies
    14
    Views
    1,480

    reading line including whitespace to string

    i have an input file that looks like this (intentional whitespace);
    456
    Unspecified user input up to 100 characters
    X 4 5 6
    X 7 8 9
    X 1 2 3

    My code runs at the moment using fscanf which...
  18. It isn't global. Both arrays are pointers to...

    It isn't global. Both arrays are pointers to double but they have been individually malloc'd (if that makes a difference).

    By 'call split_array' I meant that I am not passing it through an...
  19. Array changes value after external function that does not call the array

    My code looks like this at the moment;



    for (j=0; j<bfun_lines; j++)
    {
    printf("Attention! BEFORE main split array %i is %lf\n", j, split_array[j]);
    }
  20. Replies
    8
    Views
    2,015

    Thanks very much for looking through it! I...

    Thanks very much for looking through it! I realise how tedious it must be.

    @hk;

    #1 : I am looking at the location for a \n and incrementing if it is stored. This way of doing it accounts for...
  21. Replies
    8
    Views
    2,015

    Thanks... I used a printf statement to see...

    Thanks...

    I used a printf statement to see where the segmentation fault occurred and found it was an uninitialised pointer...

    for some reason though...fixing it has led to a complete breakdown...
  22. Replies
    8
    Views
    2,015

    Segmentation fault

    Really sorry to post such a long code. But I have no idea where this segmentation fault is coming from.

    It prints fine until it calls splitme function and then i get a segementation fault.


    ...
  23. Replies
    13
    Views
    1,803

    I did that and it is still not compiling.

    I did that and it is still not compiling.
  24. Replies
    13
    Views
    1,803

    Okay... so for this, would it be possible to...

    Okay...

    so for this, would it be possible to write bfun_split into the passing *array and call it like that?

    edit: I tried



    i=0;
    for (i=0; i<array_size; i++)
  25. Replies
    13
    Views
    1,803

    I did it here... double ReadFile(FILE...

    I did it here...




    double ReadFile(FILE *filename, int num_lines, double *array)
    {
    int i;

    rewind(filename);
Results 1 to 25 of 60
Page 1 of 3 1 2 3