简体   繁体   中英

how can i address a character in a .txt file as i would do with an array in c++?

Im new. I want to address a character in a .txt file as I would do in an array like this:

int a[100];
for(i=0; i<100; i++) {
   a[i]=x;
//or
   cin >> a[i];
//or
   cout >> a[i];
}

can I use this method to the .txt file? if I can do this with pointers, how?

As mentioned in comments you can read the contents of that .txt file into a char array, and then work on that array data.

This answer How to copy a .txt file to a char array in c++ should show you how to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM