Thread: pointers newbie... -_+

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    44

    pointers newbie... -_+

    If anyone, please give me an idea what pointers are? The simplest that I could understand... please?

    I saw lots of programs that use pointers, and I don't get it why is it so important...

    I have posted here in the message board titled: "printing from output..."
    ..there's a code there I posted which I got somewhere from the internet, and there's this asterisk(*) thing, arrggghhh, I just don't get it... lol,, xD

    What's the (*) sign's use and also, what's the (&) sign's use?


    btw, here's the code I posted from the aforementioned post:

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    
    int main(void)
    {
    	FILE *testFile;
    	int age;
    	char name[40];
    
    	system("cls");
    
    	testFile = fopen("c:\\testFile.txt", "w");
    
    	printf("\n\n\tEnter your name here: ");
    	gets(name);
    
    	printf("\tEnter your age here: ");
    	scanf("%i", &age);
    
    
    	fprintf(testFile, "The name you have inputed is: %s", name);
    	fprintf(testFile, "\nYour age is: %i", age);
    
    	fclose(testFile);
    
    	return 0;
    }
    and here's a quoted message:

    FILE *testFile declares a pointer to a FILE object. It must be a pointer (unless you REALLY want to get yourself in deep water).

    For now, you can ignore the fact that it is a pointer, tho' - because the way you'll use it throughout your life as a programmer is just "an identifier of a file" - the fact that it happens to be a pointer or that it's pointing to a file object is as meaningful as knowing the stoichometric mixture values for fuel and air in an engine when driving a car - pointless.
    I don't get it what he's trying to say.. I don't want to ignore the fact it's a pointer.. I really want to know what pointers are... So if anyone, please help me understand what pointers are.. thanks in advance... Merry Christmas and Happy New Year... ^.^

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    We have a tutorial on pointers that could be a starting point to get to know about pointers.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Also, never use gets.
    And avoid system like the plague - it is unportable.
    And also note that it is also possible to write pointers as T* var instead of T *var like the tutorial only mentions.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    Blinky's pointer video might help (link mentioned in this post). For something slightly more serious though, the cprogramming tutorial on pointers & C programming Language on howstuffworks both cover pointers pretty well (& should both cover file I/O too.)
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. delete and delete[]
    By Hunter2 in forum C++ Programming
    Replies: 13
    Last Post: 06-26-2003, 04:40 AM
  3. pointers, functions, parameters
    By sballew in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 10:33 PM
  4. Pointers pointers pointers....
    By G'n'R in forum C Programming
    Replies: 11
    Last Post: 11-02-2001, 02:02 AM
  5. Pointers pointers pointers...
    By SMurf in forum C Programming
    Replies: 8
    Last Post: 10-23-2001, 04:55 PM