Search:

Type: Posts; User: fmsguy06

Search: Search took 0.01 seconds.

  1. Replies
    20
    Views
    3,097

    You are correct. Placing the definition of a...

    You are correct. Placing the definition of a outside the brace, made it work, up to 20.





    int s;
    int a = 1;
    for (s = 0; s < numberOfChar; s++)
    {
  2. Replies
    20
    Views
    3,097

    Nor does it work before the if or after the if. ...

    Nor does it work before the if or after the if.




    int s;

    for (s = 0; s < numberOfChar; s++)
    {
    int a = 0;
  3. Replies
    20
    Views
    3,097

    Not with that code. Still all 15 on one line... ...

    Not with that code. Still all 15 on one line...



    ....

    int s;

    for (s = 0; s < numberOfChar; s++)
    {
  4. Replies
    20
    Views
    3,097

    Neither did: .... for (s = 0; s

    Neither did:



    ....

    for (s = 0; s < numberOfChar; s++)
    {

    int n = 1;
  5. Replies
    20
    Views
    3,097

    Every ten characters is what I tried, but that...

    Every ten characters is what I tried, but that apparently doesn't work, at least not that way.
  6. Replies
    20
    Views
    3,097

    Good point. Is there a way to limit the number...

    Good point. Is there a way to limit the number printed per line? I thought I could use:



    printf("&#37;10d ", x[s]);


    but that just prints a big mess...
  7. Replies
    20
    Views
    3,097

    Contents of test.txt: 15 475 3260 7102...

    Contents of test.txt:



    15 475 3260 7102 6004 8467 7024 1819 2901 3844 3613 640 7549 3096 3365 771 2759 4615 966 1021 8203 874 128 6330 2772 9943 2474 168 5536 113 737 6803 8409 6687 1490 6220...
  8. Replies
    20
    Views
    3,097

    I changed one line: fscanf(fp, "%d", &x[s]);...

    I changed one line:


    fscanf(fp, "&#37;d", &x[s]);


    so now:


    int main(int argc, char *argv[])
  9. Replies
    20
    Views
    3,097

    Sure that read from the file, but placing what I...

    Sure that read from the file, but placing what I read into the array is what's not working.




    int main(int argc, char *argv[])
    {
    int numberOfChar;
  10. Replies
    20
    Views
    3,097

    I can do it from user input, the difficult part...

    I can do it from user input, the difficult part is reading it from a file.
  11. Replies
    20
    Views
    3,097

    From a file into an array.

    I am trying to read the first value of a file, allocate an array of the amount equal to the first value, then read the rest (the number of places already defined) of the file into that array. I have...
  12. Replies
    6
    Views
    2,668

    Ah, I had: fscanf(fptr,"%s %i %i %i %f...

    Ah, I had:




    fscanf(fptr,"%s %i %i %i %f \n", &wstats[i].avg_high, &wstats[i].avg_low, &wstats[i].avg_wind, &wstats[i].avg_precip);



    Outside of main a couple days ago. That didn't run so...
  13. Replies
    6
    Views
    2,668

    Alright, changed them all to ints: int...

    Alright, changed them all to ints:




    int avg_high;
    int avg_low;
    int avg_wind;
    int avg_precip;
  14. Replies
    6
    Views
    2,668

    I have made functions before, back when I was in...

    I have made functions before, back when I was in highschool, in Java and C. but like I said, am not very good at them, and am trying to learn. Destinations, so the destination I wish them to be in is...
  15. Replies
    6
    Views
    2,668

    Reading from a file into an array

    Hello to all. I am trying to read from a file, weather.txt, into an array (using functions), and print that array once created. I believe I have before and after main done correctly, but the content...
  16. Replies
    11
    Views
    1,355

    Thanks to you all!

    Thanks to you all!
  17. Replies
    11
    Views
    1,355

    Wow, I can't believe I didn't see the semicolon....

    Wow, I can't believe I didn't see the semicolon. After all these years...that's alright everyone makes mistakes, and I thank you all for helping me! Works great now!

    Finished Product:




    int...
  18. Replies
    11
    Views
    1,355

    Just a single integer from 0-255. The numbers in...

    Just a single integer from 0-255. The numbers in the file are: 4 25 34 56 70




    if (fscanf(fp, "%d", &numberOfChar) == 1)
    printf("%d\n", numberOfChar);
  19. Replies
    11
    Views
    1,355

    The setup for fscanf is: int fscanf( FILE...

    The setup for fscanf is:


    int fscanf( FILE *stream, const char *format, ... );



    the code I tried is:
  20. Replies
    11
    Views
    1,355

    Correct, if the first character is 9, then it...

    Correct, if the first character is 9, then it somehow knows there are 9 characters total in the file it is reading from. Just not sure how to make this happen.
  21. Replies
    11
    Views
    1,355

    Using first character from a file

    I am trying to read the first character (interger) from a file, and use that number as the value of the number of characters there are in the file, telling this to the code, so it knows how much more...
Results 1 to 21 of 21