Search:

Type: Posts; User: snoikey

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    7
    Views
    5,355

    Thank you Adak, I'll do that instead. @Jim -...

    Thank you Adak, I'll do that instead.

    @Jim - probably irrelevant now, but good point, that's probably why it wasn't working.. it should have looped back round. Thank you!
  2. Replies
    7
    Views
    5,355

    Thanks for the quick response. Yep, the code...

    Thanks for the quick response. Yep, the code with the function implemented is:



    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    #include <complex.h>
    #include...
  3. Replies
    7
    Views
    5,355

    Thanks for the reply. if...

    Thanks for the reply.


    if (strcmp(string,comparison)==0) comparison=strtok(NULL,delims);

    is equivalent to


    if (strcmp(string,comparison)==0)
    {
  4. Replies
    7
    Views
    5,355

    Function not working how it should.

    I have the following code, which tokenises a file of the form:



    Air density (kg/m3) = 1.225
    Mass (kg) = 500
    Engine power (HP) = 100
    etc.
  5. Replies
    26
    Views
    6,938

    That's helpful, yes, I was treating it as a...

    That's helpful, yes, I was treating it as a wildcard symbol. The whole of the text file I'm reading is:



    Aircraft Parameters to be read. Do not add extra lines
    or swap the order of...
  6. Replies
    26
    Views
    6,938

    Thank you, that's fair enough. I've tested arra,...

    Thank you, that's fair enough. I've tested arra, it works how I think it does, param[i] and param2[i], the tokens, are coming out ok, and if there's nothing else in the tokenising loop apart from...
  7. Replies
    26
    Views
    6,938

    I'm perfectly capable of debugging it, and have...

    I'm perfectly capable of debugging it, and have done, you're right about the size of arra so I'll change that, thanks. That wouldn't be affecting the program at this stage though as the file I'm...
  8. Replies
    26
    Views
    6,938

    Sorry, didn't mean to leave out that section -...

    Sorry, didn't mean to leave out that section - there are a lot of parameters so I thought it'd be simpler to just show three, but ended up snipping a bit out that I didn't mean to.

    Attempt #2 at...
  9. Replies
    26
    Views
    6,938

    Oh, apologies. arra is the lines of the file. ...

    Oh, apologies. arra is the lines of the file. So arra[1] is line 1, arra[2] is line 2. That bit works alright definitely, because printing my tokens works fine, it's just the comparing and...
  10. Replies
    26
    Views
    6,938

    I thought since everyone on this forum has been...

    I thought since everyone on this forum has been helpful I would try and help back - I didn't know about the braces before yesterday - sorry if I insulted your intelligence.

    I -did- check the...
  11. Replies
    26
    Views
    6,938

    True, but the long program is what my supervisor...

    True, but the long program is what my supervisor wants, and with this being my first month of C, I'm proud of it so far :P
  12. Replies
    26
    Views
    6,938

    I think my question now is: Is there any other...

    I think my question now is:

    Is there any other way of doing this other than using strcmp within the tokenising loop?
  13. Replies
    26
    Views
    6,938

    You don't need the brackets round the 'if'...

    You don't need the brackets round the 'if' statement if there's only one line involved.. only learnt that yesterday from my project supervisor, this is just one part of a program that's over 1000...
  14. Replies
    26
    Views
    6,938

    Thanks for the quick replies. Ok, changed the...

    Thanks for the quick replies. Ok, changed the loop and added a check for NULL.

    I'm not completely sure what you mean by initialising the pointers - a quick search of the internet says after...
  15. Replies
    26
    Views
    6,938

    Beaten to it :P haha. *ideaS, or maybe there is...

    Beaten to it :P haha. *ideaS, or maybe there is just one to fix it!
  16. Replies
    26
    Views
    6,938

    Been playing with it some more and thought I'd...

    Been playing with it some more and thought I'd tried this already but obviously not - changing the single quotes to double quotes in strcmp it now compiles fine but comes up with a segmentation fault...
  17. Replies
    26
    Views
    6,938

    strtok and strcmp pointer issues question

    Hi everyone,
    I want to tokenise a text file with around 20 lines, and as the lines could be moved around, I want it to check the tokens for a certain word and if it contains that word, I want to...
  18. Replies
    2
    Views
    2,925

    It looks like you're right, thank you! Trying to...

    It looks like you're right, thank you! Trying to find the website I got 'degrees' from I can't.. oh well, thank you!
  19. Replies
    2
    Views
    2,925

    Fortran to C - dsin

    Hi everyone,

    I know this is the C board but hopefully someone can help.

    I've been tasked with converting a FORTRAN program to C and am having problems with the 'DSIN' function, for example:

    ...
  20. EDIT: thought I had a problem with this section...

    EDIT: thought I had a problem with this section cause it was coming up with seg faults again but turns out it was to do with trying to close a file that I hadn't actually opened.. sorry!
  21. Great, thank you, it works now - probably not the...

    Great, thank you, it works now - probably not the prettiest code ever but oh well. The i problem made me wince.. stupid mistake.



    float speed[50]={0.0};

    speed[0]=0;
    i=1;

    while...
  22. Incrementing Array - I think the solution's simple but I'm missing something

    I want to initialise an array called 'speed' which has values [0 0.5 1 1.5 ... up to 50]. I'm testing it for 5 values in the array. I know I could do it manually but I would prefer to be able to...
  23. That's useful - didn't realise a number could be...

    That's useful - didn't realise a number could be used in that way. It explains a couple of problems I've had in another program. Thanks a lot!
  24. @Adak - thanks :) that's why I thought I was so...

    @Adak - thanks :) that's why I thought I was so screwed to start with haha. I'm enjoying C a lot more now.

    @Bayint - program works fine, I tried it initially without the &s and with various...
  25. Completed, better version which sums parts of a...

    Completed, better version which sums parts of a struct.



    /* Calculates total mass of an aircraft based on the sum of all of its parts by printing
    all lines of a file data.txt into a...
Results 1 to 25 of 34
Page 1 of 2 1 2