Files!

This is a discussion on Files! within the C++ Programming forums, part of the General Programming Boards category; CODE: #include <stdio.h> #include <time.h> #include <stdlib.h> #include <string.h> #define fname "c:\rannum.f" main() { FILE *fp; int x,ran; srand((unsigned int) ...

  1. #1
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294

    Question Files!

    CODE:


    #include <stdio.h>
    #include <time.h>
    #include <stdlib.h>
    #include <string.h>
    #define fname "c:\rannum.f"
    main()
    {
    FILE *fp;
    int x,ran;

    srand((unsigned int) clock());
    fp = fopen(fname, "wb");
    for (x=0;x<21;x++)
    {
    ran = rand() % 999 + 1;
    fwrite(&ran,sizeof(int),1,fp);
    }
    fclose(fp);

    printf("\n\nFile Was Successfully Created!");

    while(getchar()!='\n');
    while(getchar()!='\n');
    ExitToShell();
    }


    i have tried this code on code warrior on mac and works fine
    but it doesnt work on windows under Dev-C++/


    error:

    1 A:\U2_a4_1.c
    `#include' expects "FILENAME" or <FILENAME>

    i also tried putting #define before header files and it gave me this
    error:

    main.c C:\DEV-C++\lib/libmingw32.a(main.o)(.text+0x8d)
    undefined reference to `WinMain@16'

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    1 - This doesn't belong in the GD forum.
    2 - USE CODE TAGS.
    3 - Sounds like you're missing a header file for DevC++.
    4 - Thank you for getting a new keyboard.

  3. #3
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    /* Moved from GD forum to C++ forum. */
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  4. #4
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    I dont think devc++ has string.h though it might have something like cstring.h

  5. #5
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    Originally posted by jdinger
    4 - Thank you for getting a new keyboard.
    LOL

  6. #6
    Unregistered
    Guest

    Arrow I think it does

    I have Dev-C++ and use string.h so I'm pretty sure it has it,

  7. #7
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Maybe it was the string class then.

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    200
    I've never heard of ExitToShell()...

  9. #9
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Well since you can doubleclick errors and check which line they are on maybe you could do that instead of lettting us guess?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 07:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 04:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 05:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21