Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C Programming Code Examples

C > Code Snippets Code Examples

Delete a file using Remove

1 2 3 4 5 6 7 8 9
/* Delete a file using Remove */ #include <stdio.h> int main() { remove("d:/urls1.dat"); return 0; }

In C, the "main" function is treated the same as every function, it has a return type (and in some cases accepts inputs via parameters). The only difference is that the main function is "called" by the operating system when the user runs the program. Thus the main function is always the first code executed when a program starts. main() function is a user defined, body of the function is defined by the programmer or we can say main() is programmer/user implemented function, whose prototype is predefined in the compiler. Hence we can say that main() in c programming is user defined as well as predefined because it's prototype is predefined. main() is a system (compiler) declared function whose defined by the user, which is invoked automatically by the operating system when program is being executed.

In the C Programming Language, you can place comments in your source code that are not executed as part of the program. Comments provide clarity to the C source code allowing others to better understand what the code was intended to accomplish and greatly helping in debugging the code. Comments are especially important in large projects containing hundreds or thousands of lines of source code or in projects in which many contributors are working on the source code. A comment starts with a slash asterisk /* and ends with a asterisk slash */ and can be anywhere in your program. Comments can span several lines within your C program. Comments are typically added directly above the related C code. /* comment here */

Remove file. Deletes the file whose name is specified in filename. This is an operation performed directly on a file identified by its filename; No streams are involved in the operation. Proper file access shall be available. The remove() function deletes the file (or directory) referred to by its string argument. To be exact, it "unlinks" the file, or deletes its filename from the file system, so that the file's contents may still exist if the file was linked to more than one name. The remove() function may or may not be able to unlink a file while it is open, depending on the given implementation. The function returns 0 on success. If remove() fails to unlink the file, it returns a nonzero value.

The return statement terminates the execution of a function and returns control to the calling function. Execution resumes in the calling function at the point immediately following the call. A return statement can also return a value to the calling function. A return statement causes your function to exit and hand back a value to its caller. The point of functions, in general, is to take in inputs and return something. The return statement is used when a function is ready to return a value to its caller.

#include is a way of including a standard or user-defined file in the program and is mostly written at the beginning of any C/C++ program. This directive is read by the preprocessor and orders it to insert the content of a user-defined or system header file into the following program. These files are mainly imported from an outside source into the current program. The process of importing such files that might be system-defined or user-defined is known as File Inclusion. This type of preprocessor directive tells the compiler to include a file in the source code program. Here are the two types of file that can be included using #include:





C language program code depending upon the number of elements, the required size is allocated which prevents the wastage of memory. If no memory is allocated, error is



C Program to performs Comb sort on array of integers. "Comb Sort" is a comparison sorting algorithm. This sort is 'Exchange sort', similar to 'Bubble Sort'. Function to find the new gap


C Program take a octal number as input and store it in the array octalnumber and using switch statement access each digit of a octal number and print its equivalent binary value