How to use abort() to cause abnormal program termination in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>
 
int main(void) 
{
    FILE *fp = fopen("d:\\dataaaa.txt","r");
    if (fp == NULL) 
    {
       fprintf(stderr, "error open file\n");
       abort();
    }
 
    printf("open file success\n");
    fclose(fp);
    
    return 0;
}
  
/*
run:
 
error open file

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

*/

 



answered Aug 24, 2016 by avibootz

Related questions

2 answers 248 views
1 answer 117 views
1 answer 139 views
139 views asked Dec 22, 2021 by avibootz
1 answer 131 views
1 answer 151 views
...