Objective-C learning-2: Count the length of words in a text file

Source: Internet
Author: User

 

/** Count the word length in the text file **/# import <Foundation/Foundation. h> int main (INT argc, const char * argv []) {file * wordfile = fopen ("words.txt", "R"); char word [1, 100]; while (fgets (word, 100, wordfile) {// change the linefeed to '\ 0' word [strlen (Word)-1] =' \ 0 '; nslog (@ "% s is % d characters long", word, strlen (Word);} fclose (wordfile); Return 0 ;}

 

 

How can I automatically copy the words.txt file to the target directory?:
Under targets, right-click the project name and add new build phase-> new files phase
Select executablesas as the target, and then drag words.txt to the created "Copy files (1)" build phase.

 
How to add command line parameters to a debugging project:
Double-click executablesProgramName, click the plus sign under arguments, and enter the startup parameter.

Related Article

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.