c - calculation of the length of the file doesn't work -


  # शामिल "stdio.h" #include "stdlib.h" int main () {FILE * fp; Int noOfLines = 0; Char fname [] = "Rtl_Prod_Id.txt"; printf (fname); fp = fopen (fname, "आर"); चार च; // हर लाइन के लिए looping करें {ch = fgetc (fp); अगर (ch == '\ n') noOfLines ++; } जबकि (ch! = EOF); // अंतिम पंक्ति से पहले लाइन अगर (ch! = '\ N' & amp; amp; NoOfLines! = 0) noOfLines ++; fclose (एफपी); printf ( "% d", noOfLines); वापसी 0; }   

मैं बस मेरी फाइल में लाइनों की संख्या की गणना करने की कोशिश कर रहा हूँ वही मुझे कोई परिणाम नहीं लौटाता है

मैं क्या कर रहा हूँ जो संभव गलतियाँ हैं

पर्यावरण: एएक्स और कंपाइलर: सीसी

धन्यवाद

संपादित करें: मेरे प्रोग्राम को सफलतापूर्वक संकलित किया जाता है, लेकिन इसे निष्पादित करते समय। ओट फाइल में यह कुछ भी चालू नहीं होता

पीएस: हालांकि मुझे जवाब मिल गया है। करने के लिए धन्यवाद । मुझे चार च; से int ch; बदलना पड़ा। लेकिन मुझे आश्चर्य है कि क्यों? चार घोषणाओं में क्या गलत है? । जैसा कि मैं '\ n' और EOF वर्णों की जांच करने जा रहा हूं, इसलिए पूर्णांक क्यों?

यह एक जंगली शॉट है, लेकिन लाइन को बदलने

  चार च;   

से

  int ch;   

उपयुक्त है fgetc का वापसी प्रकार है int , नहीं char

Comments

Popular posts from this blog

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

sql - PostgreSQL automatically update row at specific date -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -