Thread: help please

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    3

    Angry help please

    Does anybody have any idea what I have done wrong here? My isSentence function doesn't seem to be working. No doubt a simple answer, but for the life of me I can't find it. Cheers.

    #include <stdio.h>

    FILE *myfile;

    void isSentence( const char *w);

    int main (void)

    {
    const char test [] = "The rain in spain ";

    char name[20];

    char c;
    int size ;
    printf("Please input file name\n");
    gets( name);

    myfile=fopen("name", "w");
    if(name==NULL)
    {
    printf("Error creating file");

    }
    else
    {
    printf("File created\n");

    }

    size=strlen(test);
    printf("%d\n", size);
    fprintf(myfile, "%s", test);
    fclose(myfile);
    myfile=fopen("test", "r");

    if(!myfile)
    {
    printf("\aCan't open file %s.\n", name);
    exit (0);
    }
    else
    {printf("file opened\n");}
    isSentence(test);

    void isSentence(const char *w)
    {
    while(*w++)
    putchar('=');

    putchar('\n');
    }




    return (0);
    fclose(myfile);

    }

  2. #2
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    use code tags and I'll have a look at it

    code tags:
    [ code ]
    code in here
    [/ code]
    without the spaces

  3. #3
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Oh and tryu putting you isSentence funcvtion outside of main

    and put fclose(); before return 0;

Popular pages Recent additions subscribe to a feed