Skip to content

A simple c libray made for checking if a program is ran for the first time or not

License

Notifications You must be signed in to change notification settings

MaybeHawk1/C-Run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C-Run

A simple singly library file for checking if an application has been ran for the first time. This simply creates a run.flag file that will be made on the first run. If this file exists it means that the program has been ran before, if it does not exist that means it's the first time the program has been opened.

Table of Contents

Examples

#include <stdio.h>
#include "What ever file you rename firstran.h to"

int main() {
    if (WasRan() == 0) { // Function WasRan() Returns 0 if the file exists and 1 if it does not
        printf("It was ran before");
    } else {
        printf("it was not ran");
    }

    return 0;   
}

As i said the function WasRan() returns 0 if the file does infact exists and 1 if it does not. So you could also do something like this:

#include <stdio.h>
#include "What ever file you rename firstran.h to"

int main() {
    int WasItRan == WasRan();

    if (WasItRan == 0) { // Function WasRan() Returns 0 if the file exists and 1 if it does not
        printf("It was ran before");
    } else {
        printf("it was not ran");
    }

    return 0;   
}

You may also want to pass in a custom file name for the flag file. You can do that by passing in the filename as an argument. For example:

#include <stdio.h>
#include "What ever file you rename firstran.h to"

int main() {
    int WasItRan == WasRan("filename.flag");

    if (WasItRan == 0) { // Function WasRan() Returns 0 if the file exists and 1 if it does not
        printf("It was ran before");
    } else {
        printf("it was not ran");
    }

    return 0;   
}

If you don't want to have a custom file name simply just don't pass any arguments when calling WasRan.

Return Values

Value Meaning
1 The file doesn't exist
0 The file exists
-1 Creation of the flag file failed

Dependencies

Just stdio.h

FAQ

Q: How do i reset this? A: Simply just delete the file

Q: Will more features be added? A: Yes defenitly

Side Note

This was made in like 10 Minutes. Hate all you want im proud of it

About

A simple c libray made for checking if a program is ran for the first time or not

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages