Use a program to name multiple file strings + numeric types

Source: Internet
Author: User

Use a program to name multiple file strings + numeric types

In many cases, we create many files, and then output them by string name. So we can use img0.jpg img1.jpg img2.jpg img3.jpg.

The following are implemented in c ++ and c respectively.

C ++

# Include

 
  
# Include

  
   
# Include

   
    
Using namespace std; int main () {for (int I = 0; I <10; I ++) {strstream ss; string ii; ss <

    
     
> Ii; string a = "img" + ii + ". jpg"; cout

     

      

# Include

       
        
# Include

        
         
# Include

         
          
Int main () {for (int I = 0; I <10; I ++) {char str [3] = {'\ 0'}; itoa (I, str, 10); char buf [12] = "img"; char * jpg = ". jpg "; strcat (buf, str); strcat (buf, jpg); printf (" % s \ n ", buf );}}

         

        

       
Because it is an experiment, the final result is displayed, not as a file name.



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.