Debug assertion failed! error

Discussion in 'MFC' started by keerth516, Nov 22, 2011.

  1. keerth516

    keerth516 New Member

    Joined:
    Nov 21, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    how to solve this error.I am trying to read each character from a file and want to display it on console window.But could display the result in visual studio 2008(VC++).I am getting the debug assertion failed !!.could you please let me know where i went wrong.
    here is my code :
    Code:
    #include "stdafx.h"
    int main()
    {
    	FILE* fp;
    	char c;
    	fp=fopen("21-11-11.txt","r");//open the specific file in read mode
    	if(fp==NULL)//if the file doesnt conatins any thing or nullvalues return the below statement
    	{
    		printf("File not Found!!");//file not fonde in console window.
    	}
    	else
    	{
    		do
    		{
    			c=fgetc(fp);// get each character from file
    			putchar(c);// print each character 
    			//printf("%c",c);
    		}while(c!=EOF); //check until the end of file
    	
    	}
    	fclose(fp);//close the file
    	
    }
    please any suggestion to resolve this issues :debug assertion failed" in VC++

    Thanks in advance
     
    Last edited by a moderator: Nov 22, 2011

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice