1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <windows.h> int main() { HANDLE hFind; WIN32_FIND_DATA win32fd; hFind = FindFirstFile( "C:\\*.*" , &win32fd); if (hFind == INVALID_HANDLE_VALUE) { return 1; } do { if (win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { printf ( "%s (DIR)\n" , win32fd.cFileName); } else { printf ( "%s\n" , win32fd.cFileName); } } while (FindNextFile(hFind, &win32fd)); FindClose(hFind); return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <vector> #include <iostream> int main() { using namespace std; vector< int > array; int i; for ( i = 0; i < 10; ++i ) { array.push_back( i ); } vector< int >::iterator it = array.begin(); // イテレータのインスタンス化 while ( it != array.end() ) // 末尾要素まで { cout << *it << endl; // *演算子で間接参照 ++it; // イテレータを1つ進める } return 0; } |