Search:

Type: Posts; User: sixstringsgaret

Search: Search took 0.01 seconds.

  1. Replies
    32
    Views
    2,742

    It's ok i've given up trying to return a value so...

    It's ok i've given up trying to return a value so i've made the function void and just printing the line within the function itself rather than main.

    Thank you so much for your help laserlight!
  2. Replies
    32
    Views
    2,742

    Wait that can't be it. oops

    Wait that can't be it. oops
  3. Replies
    32
    Views
    2,742

    I think I know what it might be. I am reading a...

    I think I know what it might be. I am reading a file as the parameter of both functions within the comStaRatio function and therefore I think the file isn't undergoing rewind() for the second...
  4. Replies
    32
    Views
    2,742

    Sorry, yes it works fine! comments:2...

    Sorry, yes it works fine!

    comments:2
    statements: 8
    therefore .25
  5. Replies
    32
    Views
    2,742

    I am using Bloodshed Dev-C++ I found something...

    I am using Bloodshed Dev-C++
    I found something weird... If I print ratio within the function, it works fine but still returns 0.00
  6. Replies
    32
    Views
    2,742

    Could it be to do with my compiler?

    Could it be to do with my compiler?
  7. Replies
    32
    Views
    2,742

    Even if I just set ratio to say 2 and comment out...

    Even if I just set ratio to say 2 and comment out the division, it still returns a 0.00 so it's not a casting error.
  8. Replies
    32
    Views
    2,742

    I don't know how to illustrate the problem any...

    I don't know how to illustrate the problem any more simple.
    It works with int values but not with float. When I change to float it just always returns 0.00.
    I can't see the problem. :(
  9. Replies
    32
    Views
    2,742

    No I can't say that I do. The two parameters you...

    No I can't say that I do.
    The two parameters you have in green are ints yes but comStaRatio returns a floating point number.
  10. Replies
    32
    Views
    2,742

    Uh oh. Whenever I try to change the function and...

    Uh oh. Whenever I try to change the function and the function call to float it doesnt work!


    float comStaRatio(int comments, int statements)
    {
    float ratio=1;

    ...
  11. Replies
    32
    Views
    2,742

    laserlight you are a legend! I can;t believe i...

    laserlight you are a legend! I can;t believe i was so stupid not to realise that the answer actually is 0!!!

    Thank you!
  12. Replies
    32
    Views
    2,742

    I'm unsure, but it returns 0.

    I'm unsure, but it returns 0.
  13. Replies
    32
    Views
    2,742

    Function call another function

    How do you call a function in a function?

    This is the function:


    int comStaRatio(int comments, int statements)
    {
    int ratio=1;

    ratio=comments/statements;
  14. I forgot to say that i intend going through the...

    I forgot to say that i intend going through the file by 1 position each time
    eg:
    int number; int another_number;

    first: int number //first occurance
    second: nt number;
    third: t...
  15. All I want to do is search the c file for int,...

    All I want to do is search the c file for int, char etc... which are listed in the lookup file and therefore count how many variables are in the c file.
    I am reading the c file 10 chars at a time,...
  16. This is what I have now: int varCount(FILE...

    This is what I have now:


    int varCount(FILE *a_file)
    {
    FILE *lookup=NULL;
    lookup=fopen("lookup.txt","r");
    char curr_var[10];
    char c[10];
    char *pch;
  17. Error fixed. How do I search for the string in...

    Error fixed.

    How do I search for the string in the c file?
  18. This is what I have so far: int...

    This is what I have so far:



    int varCount(FILE *a_file)
    {
    FILE *lookup=NULL;
    lookup=fopen("lookup.txt","r");
    char curr_var[10];
  19. search file for values in lookup table

    I have a .c file and I have a lookup file.

    The lookup file is like follows:

    ¬int
    ¬short
    ¬long
    ¬double
    ¬float
    ¬char
Results 1 to 19 of 19