diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-788031A5-75C1-420E-9E2B-71E09FF08ADF.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-788031A5-75C1-420E-9E2B-71E09FF08ADF.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,52 @@ + + + + + +Example +using <codeph>E32Main()</codeph> +

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

+
    +
  • Modify the MMP file as mentioned earlier.

  • +
  • Create a trap handler using CTrapCleanup.

  • +
  • Call the method within TRAPD.

  • +
  • Delete the trap handler.

  • +
+#include <stdio.h> +#include <string.h> +#include <e32base.h> + +void doExampleL(void) +{ + FILE* fd; + char* fileName = "C:\\test.txt"; + char *buf = "Hello world from E32Main()"; + fd = fopen(fileName, "w"); + if (fd == NULL) + { + printf("Unable to open the file (%s)", fileName); + return; + } + if (fwrite(buf, sizeof(char), strlen(buf), fd) < 0 ) + { + perror("write fails."); + } + fclose(fd); +} + +GLDEF_C TInt E32Main() + { + CTrapCleanup* cleanup=CTrapCleanup::New(); + TRAPD(error,doExampleL()); + delete cleanup; // destroy cleanup stack + return 0; // and return + } + +
\ No newline at end of file