I get a dialog box that says abort retry or ignore My
problem is when i compile it gives my that error can someone help me
/* Fig 9.7: fig09_07.c */
/* Using the p, n, and % conversion specifiers */
include<stdio.h>
int main ( )
{
int *ptr; /* define pointer to int */
int x = 12345; /* initialize int x */
int y; /* define int y */
ptr = &x; /* assign address of x to ptr */
printf( "The value of ptr is %p\n", ptr );
printf( "The address of x is %p\n\n", &x );
printf( "Total characters printed on this line:%n", &y );
printf( " %d\n\n\n", y );
y = printf( "This line has 28 characters\n" );
printf( "%d characters were printed\n\n", y );
printf( "Printing a %% in a format control string\n" );
I can not be certain because the OP has not given any info on His system/dev environment but from the sound of it He is getting a debug assertion failed because VC dose not have the 'n' specifier enabled by default. If this is the case then the OP will need to add _set_printf_count_output(1); at the start of main:
#include<stdio.h>
int main ( )
{
_set_printf_count_output(1);
int *ptr; /* define pointer to int */
int x = 12345; /* initialize int x */
int y; /* define int y */
ptr = &x; /* assign address of x to ptr */
printf( "The value of ptr is %p\n", ptr );
printf( "The address of x is %p\n\n", &x );
printf( "Total characters printed on this line:%n", &y);
printf( " %d\n\n\n", y );
y = printf( "This line has 28 characters\n" );
printf( "%d characters were printed\n\n", y );
printf( "Printing a %% in a format control string\n" );
return 0; /* indicates successful termination */
} /* end main */
helios, %n will indeed assigns the printf count to the variable y.