#include #include #include #include void RelativeToAbsolute(const char* relativePath) { char absolutePath[_MAX_PATH]; // 相対パスから絶対パスへの変換 if (_fullpath(absolutePath, relativePath, _MAX_PATH) != NULL) { printf("Absolute Path: %s\n", absolutePath); } else { perror("Error getting absolute path"); } } void AbsoluteToRelative(const char* absolutePath) { char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; char relativePath[_MAX_PATH]; // 絶対パスから相対パスへの変換 _splitpath_s(absolutePath, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); _makepath_s(relativePath, _MAX_PATH, NULL, dir, fname, ext); printf("Relative Path: %s\n", relativePath); } int main() { const char* exampleRelativePath = "test.txt"; const char* exampleAbsolutePath = "C:\\Users\\SEEDAGX\\source\\repos\\PathChange\\PathChange\\test.txt"; printf("Converting Relative Path to Absolute Path:\n"); RelativeToAbsolute(exampleRelativePath); printf("\nConverting Absolute Path to Relative Path:\n"); AbsoluteToRelative(exampleAbsolutePath); return 0; }