Contact Us

Scripts: C :: Pointers :: Library Article #1

Developer's Section

Using Pointers in C
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (1850)

Brief explanation on how to create Pointers

A pointer in C is a reference to a memory location in your computer. Pointer can be of type int or string, and depending on how you use it you can change the refence.

Let's take a look at Strings with Pointers:

 Code Snippet 1

#include <stdio.h>

main(argc, argv, envp) {

char myString[40] = "This is my new String";

char *myPointer; //pointer of type char
                          //referenced to a memory location
myPointer = &myString[0]; //copy address location of
                                         //first char to myPointer

*myPointer = "Assign Pointer to a new variable"; 

//output result

printf("the value of myPointer is: %d\n",*myPointer); 


Now, here is how you can use Integers with Pointers:

 Code Snippet 2

#include <stdio.h>

main(argc, argv, envp) {

    int myInt = 53497;  //an Integer

    int *myIntegerPointer;  //integer pointer

    myIntegerPointer = &myInt;  //initialize

    *myIntegerPointer = 24742;  //reset pointer at
                                               //memory location
                                               //put new value 24742
      printf("myInt is equal to %d\n", myInt);

See other Scripts in Pointers

Submit Your Scripts:

System Message:
  • Your C script has been sent. Please allow 48 hours for processing.

If you would like to have your C scripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]