These days im using xcode and
its a bit of annoyingly good amounts of changes from borland which im used to
But i keep getting error for this

printf ("\nThe amount of First Class cars Stocks remaining are: %d", &stock1);

(while stock1 is declared: int stock1)

and it says format types specifies type "int" but argument has type "int*"

i dont understand what this means..
is a pointer being used at int?

the more puzzling thing for me is that when i take out the "&" for some parts of the code:

fprintf (Stocks,"\nThe amount of First Class Stocks remaining are: %d\n", stock1);

it shows no errors
although this method doesnt work in the earlier code

I'm sorry if this is too obvious a problem
but i've never gone out of using the & sign

but please i need any help whatsoever

scanf() requires the address of the variable it will change. printf() does not.

& is the address of operator.

Clarifying what Adak said, here's what you should know:

The & symbol (address-of operator) will return the address of a variable (where it is stored in memory). If you have declared an integer called foo, then &foo would be its address.

When you're dealing withprintf(), you only really need to know the values of these variables. You don't need to know where they're being stored, because you only really care whether foo is a 3, a 12, or whatever number. You will never use & in printf() unless you plan on printing out raw memory addresses, which you will almost never do.

Then scanf() function actually needs to modify your data. In order for it to do this, having a value isn't enough, it actually needs to know where your variable is stored in memory so scanf() can modify it. This is why scanf() requires an & sign for most types.

The only exception to this rule is strings. A string esssentially is a memory address that points to the first character in a group of characters, so neither printf() nor scanf() take the & symbol in this case.

You will never use & in printf() unless you plan on printing out raw memory addresses, which you will almost never do.

Never say never. ;) printf() supports a %n specifier that assigns the number of characters written up to that point:

#include <stdio.h>

int main(void)
{
    int n = 0;

#ifdef _MSC_VER
    // Visual Studio disables %n by default and only provides a runtime way to enable it...
    _set_printf_count_output(1);
#endif

    printf("Printing 22 characters%n\n", &n);
    printf("Printed %d characters\n", n);

    return 0;
}

However, that specifier is viewed as a security risk, and some compilers (notable is Visual Studio, as in the example) will disable it.

A string esssentially is a memory address that points to the first character in a group of characters

Noting, of course, that this is a conversion that happens implicitly when arrays are used in value context and it's important to recognize that strings in general aren't inherently pointers.

Never say never. ;) printf() supports a %n specifier that assigns the number of characters written up to that point:

Like I said, you will never use them (as in mattboy64). ;)

Thank you so much!
I practically understand everything
except what deceptikon posted :(
but i guess like what Tumlee said,

Like I said, you will never use them (as in mattboy64). ;)

except what deceptikon posted :(

Sadly, that happens a lot. Today at work I was getting frustrated because a client just didn't seem to grok my explanations about how macro translation in some of our software's text areas worked... :(

Like I said, you will never use them (as in mattboy64). ;)

Yeah...want to know how many times I was told I'd never use something when I was a beginner that I use often now? ;)

hahahah
you are right though
since I am planning to get deep in coding
I should stop underestimating :)

Yeah...want to know how many times I was told I'd never use something when I was a beginner that I use often now? ;)

Well then, hopefully by the time he uses it, he'll have forgotten that I told him he'll never use it! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.