Symbian3/PDK/Source/GUID-6F78B032-00EC-4638-8B65-88CA99075B4F.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-6F78B032-00EC-4638-8B65-88CA99075B4F" xml:lang="en"><title>Example
       
    13 using <codeph>main()</codeph></title><shortdesc/><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>A simple example using <codeph>main()</codeph> as an entry
       
    15 point is described below. The example writes a text to a file.</p>
       
    16 <ul>
       
    17 <li><p>Modify the MMP file as mentioned before.</p></li>
       
    18 <li><p>Do usual C style coding. </p></li>
       
    19 </ul>
       
    20 <codeblock xml:space="preserve">#include &lt;stdio.h&gt;
       
    21 #include &lt;string.h&gt;
       
    22 
       
    23 int main(void)
       
    24 {
       
    25     FILE* fd;
       
    26     char* fileName = "C:\\test.txt";
       
    27     char *buf = "Hello world";
       
    28     fd = fopen(fileName, "w");
       
    29     if(fd == NULL)
       
    30 		{
       
    31 		printf("Unable to open the file (%s)", fileName);
       
    32 		return -1;
       
    33 		}
       
    34     if (fwrite(buf, sizeof(char), strlen(buf), fd) &lt; 0 )
       
    35         {
       
    36     	perror("write fails.");
       
    37         }
       
    38     printf("File (%s) is created successfully.", fileName);
       
    39     fclose(fd);
       
    40     getchar();
       
    41     return 0;
       
    42 	}</codeblock>
       
    43 </conbody></concept>