Example using main()

A simple example using main() as an entry point is described below. The example writes a text to a file.

  • Modify the MMP file as mentioned before.

  • Do usual C style coding.

      #include <stdio.h>
#include <string.h>

int main(void)
{
    FILE* fd;
    char* fileName = "C:\\test.txt";
    char *buf = "Hello world";
    fd = fopen(fileName, "w");
    if(fd == NULL)
		{
		printf("Unable to open the file (%s)", fileName);
		return -1;
		}
    if (fwrite(buf, sizeof(char), strlen(buf), fd) < 0 )
        {
    	perror("write fails.");
        }
    printf("File (%s) is created successfully.", fileName);
    fclose(fd);
    getchar();
    return 0;
	}