Recently I just learned some basics of C Programming.After learning I made a simple project with C.My project is to make a program that create .html file with some valid Html5 codes.
Here is my codes for main.c :)
This C Program Will Create Basic HTML5 Files.
//This is the main Function
printf("==========================WELCOME TO HTML5 FILE CREATOR=========================\n");
printf("Version : 1.0 \nCreated by : Nazmul Hossain Nihal \n\n");
printf("Your file will look like this: \n\n");
printf("\t&lt;!DOCTYPE html&gt;\n\t&lt;html lang=\"en\"&gt;\n\t\t&lt;head&gt;\n\t\t\t&lt;title&gt;This File Was Generated by a C Program&lt;/title&gt;\n\t\t\t&lt;meta charset=\"UTF-8\" /&gt;\n\t\t&lt;/head&gt;\n\t\t&lt;body&gt;\n\t\t\t&lt;h1&gt;This is a HTML5 File&lt;/h1&gt;\n\t\t&lt;/body&gt;\n\t&lt;/html&gt;\n\n");
printf("Name your file: ");
char FileData = "&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n\t&lt;head&gt;\n\t\t&lt;title&gt;This File Was Generated by a C Program&lt;/title&gt;\n\t\t&lt;meta charset=\"UTF-8\" /&gt;\n\t&lt;/head&gt;\n\t&lt;body&gt;\n\t\t&lt;h1&gt;This is a HTML5 File&lt;/h1&gt;\n\t&lt;/body&gt;\n&lt;/html&gt;";
FILE * Fpointer;
Fpointer = fopen(FileName,"w");
printf("Your File %s has been successfully created \n" , FileName);
This one is easier than the first one.You have to give the path of the file that you want to move in the first parameter of the rename() function. Then give the new path for the file in the second parameter (give the path with the file name).
If your site is in a different language than English then you must need to display date and time in that language in your site.It is very easy to display date in any language with php.
You can do this by using str_replace() function.All you have to do replace the numbers, months and day names with your wanted language’s words. Str_replace() function is used to replace parts of a PHP string with new value.
I am going to create a function named translated_date_and_time() and do every thing inside that and when I call this function anywhere in my php script it will display date in the language that I want.I am going to use Bengali here.
Definition of the translator function:
//First take the value of date() function
$date = date('g:i A F j, Y');
//Translate the numbers
$english_numbers = array(0,1,2,3,4,5,6,7,8,9);
$translated_numbers = array('০','১','২','৩','৪','৫','৬','৭','৮','৯');
$date = str_replace($english_numbers,$translated_numbers,$date);
//Translate the months
$english_months = array(
$translated_months = array(
$date = str_replace($english_months,$translated_months,$date);
//Translate Am and PM
$english_am_pm = array("AM","PM");
$translated_am_pm = array('এম','পিএম');
$date = str_replace($english_am_pm,$translated_am_pm,$date);
Now it is time to call our function:
. . .
This was originally posted on one of my old blog – CodingWar.com
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.