Home C-tutorials C Tutorials
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

C Tutorials

Advertisement
C Tutorials: array example in c programming

C Tutorials

     

In this section we have given large number of tutorials on C programming Language. C programming language is used to develop applications mostly for Linux environment. But is it not limited to only Linux environment. You can compile the C program for any platform and then run.

C is one of the most used programming Language for developing applications.

To test the examples you will be needing a C compiler on your machine.

Here are the tutorials of C programming language.

  1. C Array copy example
    The example below contains two arrays: array1 and array2 with sizes 5 respectively. Here the size of an array states its capacity to hold maximum number of values.
      
  2. To declare an array in C, you have to specify the name of the data type and the number of elements inside the square brackets.
      
  3. C Array default values
    The example below contains an array arr of integer type. The maximum size of the array is 4.
     
  4. C Array length example
    An array is a contiguous group of data items with the same name and data type. In order to get the length of an array, we have used the sizeof operator.
     
  5. C array of pointers
    A pointer is a variable that contains the memory location of another variable. The values you assign to the pointers are memory addresses of other variables (or other pointers).
      
  6. C array sort example
    For sorting an array, we have used the qsort function. This function provides the implementation of quicksort algorithm to sort the elements of an array .
     
  7. C String length
    In this section, you will learn how to determine the length of a String in C. You can see in the given example, we have declared a string and initialize a variable i to 0.
      
  8. C Break with Switch statement
    The switch case statements allows to control complex conditional and branching operations. It include any number of case instances, but should not have the same value.
      
  9. C Break for loop
    The break statement terminates the execution of the enclosing loop or conditional statement. In a for loop statement, the break statement can stop the counting when a given condition becomes true.
     
  10. C break continue example
    The continue statement provides a convenient way to force an immediate jump to the loop control statement. The break statement terminates the execution of the loop.
      
  11. Array of String using Pointers
    The declaration of an array of character pointers is an extremely useful extension to single string pointer declarations. In the example below, A two element array of character pointers where each element is a pointer to a character.
      
  12. C Array of String
    A String is an array of char objects. An array of string can be declared and handled like a 2d(two dimensional) arrays. You can see in the given example that we have declare a 2 dimensional character array consisting of three 'rows' and twelve 'columns'.
      
  13. C String to Int
    In this section, you will learn how to convert a string represented value into an integer represented value in C.
     
  14. C define Macro
    Macros are the identifiers that represent statements or expressions. To associate meaningful identifiers with constants, keywords, and statements or expressions,  #define directive is used.
     
  15. C Current Time
    The header file <time.h> provides all date and time functions. In the given example, the time() function determines the current time in seconds and assigns it to time_t type variable t.
     
  16. C String Remove Spaces
    In this section, you will study how to remove spaces from the string. You can see in the given example, we have define the string and passed it into two character pointers.
     
  17. C Pointer to a function
    C provides a special feature of  pointer to a function. As you know  that every function defined in C language have a base address attached to it.
      
  18. C Multiple Indirection
    C permits the pointer to point to another pointer. This creates many layers of pointer and therefore called as multiple indirection. A pointer to a pointer has declaration is similar to that of a normal pointer but have more asterisk sign before them.
      
  19. C Goto Statement
    The goto statement is a jump statement which jumps from one point to another point within a function. The goto statement is marked by label statement.
      
  20. C GMT Time
    In this section, you will study how to get the gmt time in C. GMT stands for Greenwich Mean Time. In the given example, the time() function determines the current time in seconds and assign it to t.
      
  21. C file write example
    Here we are using the library function fwrite() to write the data into the file. You can see in the given example, we have stored the string into the buffer which is to be written into the specified file 'Hello.txt'.
      
  22. C file rename
    This section illustrates you to rename a file in C. You can see in the given example that we want to replace the name of the text file MYFILE.txt with HELLO.txt.
     
  23. C file read example
    This section demonstrates you to read a line from the file. You can see in the given example, we prompt the user to enter the name of the file to read.
      
  24. C file open example
    The header file <stdio.h> provides several functions related to file operations. Here we are going to open a file using library function fopen(). You can see in the given example, we have used the type FILE in order to store the information related to file stream.
      
  25. C file Last Modified Date
    You can see in the given example that we want to get the last modified date of the specified file Hello.txt. For this, we have defined the library function strftime() provided by the header file <time.h> that formats the time represented in the structure according to the formatting rules defined in format and stored into t.
     
  26. C file delete example
    This section illustrates you to delete a file in C. You can see in the given example that we want to remove the file HELLO.txt. For this, we have used the library function remove() which deletes the file HELLO.txt.
     
  27. C Dynamic Array
    The dynamic array is an array data structure which can be resized during runtime which means elements can be added and removed.  You can see in the given example that we prompt the user to enter the number of elements that he want to set into the array.
      
  28. C String Copy
    In this section, you will learn how to copy the string in C. You can see in the given example, two string variables st1 and st2 are created. A string is passed to the st1.
      
  29. C String Concatenation
    In this section you will study how to concatenate the two strings in C. You can see in the given example, we have declared two strings in order to combine the strings.
     
  30. C String Compare
    In this section, you will learn how to compare two strings. You can see in the given example, the program prompts the user to enter the two strings one by one.
     
  31. C Replace String
    Here a function pointer replace is created in which variables st, orig, repl of pointer type are declared. The st represents the string, orig represents the substring which is to be replaced and repl represents the replaced substring.
      
  32. C String lowercase
    In this section, you will study how to convert the string to lowercase. You can see in the given example, we have define a string in uppercase characters.
     
  33. C String Join
    In this section, you will learn how to join the strings. You can see in the given example, we have define two strings and initializes two integer variables length1 and length2 to 0.
     
  34. C get Substring from String
    This section illustrates you how to get the substring using library function. You can see in the given example, we have used the library function strstr() provided by the header file <string.h>.
     
  35. C Temperature Converter
    Here we are going to illustrates you how to convert temperature from Celsius to Fahrenheit in C. You can see in the given example, we prompt the user to enter the temperature in celsius.
     
  36. C Structure Pointer
    This section illustrates you the concept of Structure Pointer in C. You can see in the given example, we want to access the employee's information through structure pointer.
      
  37. C Structure example
    Structures in C defines the group of contiguous (adjacent) fields, such as records or control blocks. A structure is a collection of variables grouped together under a single name.
      
  38. C String uppercase
    In this section, you will learn how to convert a string value in to uppercase. In the given example, we have define a string in lowercase characters.
      
  39. C String Tokenizer
    In this section, you will learn how to use strtok() function to break the string into a series of tokens. You can see in the given example, we have define a string and a pointer.
      
  40. C String Substring
    In this section, you will learn how to get the substring from a string in C. You can see in the given example, a string and a method substring() is created.
     
  41. C String Reverse
    In this section, you will study how to reverse a string. You can see in the given example, a recursive function reverse(int i) is created. Inside the method, we are calculating the length of a specified string using a library function strlen().
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 27, 2005

Ask Questions?    Discuss: C Tutorials   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Jerenny Mark Lazarte
September 12, 2012
Ask

HOw to open c file assuming the file contains characters , count the number of letter "a" inside the file write a function that will add 3 numbers write a function that will determine if a number is odd or even
Parthu
September 27, 2012
C

May i know this " $* " symbol represents?
DMCA.com