C Simple Program

Source: Internet
Author: User

Enter a directory file name from the keyboard;

Print A. c file to determine whether the curly braces appear in pairs;

#include <stdio.h>int main () {file *rfile = null;char*pput=null;char name[100]  =  "0"; int count=5;char ch= ' 0 '; flag:printf ("Please enter the directory and name of the file you want to read (EG:C:\\WINDOWS\\TEST.C): \ n"); scanf ("%s", name),     rfile = fopen (name, "R");if  (rfile == null) { printf ("The file you want to access does not exist, please re-enter the directory!") \ n "); goto flag;} else{while  (ch != eof) {ch = fgetc (rfile);p Utchar (CH);} Fclose (Rfile); Rfile = fopen (name,  "R");ch =  ' 0 ';while  (ch!= eof) {     CH&NBSP;=&NBSP;FGETC (Rfile);     if (ch== ' {')     count++;     if  (ch== '} ')     count--;}     if  ( 5 == count )     printf ("\ n curly braces appear in pairs!") ");    else if  (count > 5)     printf (" \ n a positive or a parenthesis is more than an inverse or parenthesis  %d\n***********************",  count - 5);     else    printf (" \ n the inverted curly brace is more than the curly brace  %d\n*************************************** ", 5 - count);} return 0;}


C Simple Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.