コード:
#include<stdio.h>
#include<string.h>
int main (int argc, char *argv[]) {
char folderPath[1024];
int i = 0;
for (i; i < (strlen(argv[0]) - 7); i++) {
folderPath[i] = argv[0][i];
}
printf("Command: afplay %ssong.mp3\n", folderPath);
system("afplay %ssong.mp3", folderPath);
return 0;
}
すべての出力:
Command: afplay /Users/carloabelli/Desktop/FUNNY/song.mp3
Error: AudioFileOpen failed (-43)
ターミナルからコマンドを実行すると、完全に機能します。私は何がうまくいかないのだろうと思っていました。