|
|
|
#1 (permalink) | |||||||||||||
|
Every base is base 10
|
Are the standard C libraries different for OSX? The following bit of code compiles on my school's linux and unix servers, but not my OSX install.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#define NAME_MAX 255
int main(int argc, char *argv[]){
char str_buffer[NAME_MAX];
char *curr_dir_path;
DIR *dir;
struct dirent *entry;
/* get path and open directory */
getcwd(str_buffer, NAME_MAX);
printf("Buffer contents: %sn", str_buffer);
curr_dir_path = malloc(strlen(str_buffer) * sizeof(char));
strncpy(curr_dir_path, str_buffer, NAME_MAX);
printf("dir path: %sn", curr_dir_path);
dir = opendir(curr_dir_path);
while(entry = readdir(dir)){
printf("Entry name: %sn", entry->d_name);
}
return 0;
}
If it matters the code simply lists all files in the directory its executed from
|
|||||||||||||
|
|
|
|
#2 (permalink) | ||||||||||||||
|
Miscelaneous
|
Quote:
I do suggest you use Linux over OSX myself however thats merely my opinion, i only mention is since you seam (no offense here if i am wrong) to think they are the same.
__________________
|
||||||||||||||
|
|
|
|
#3 (permalink) | ||||||||||||||
|
Every base is base 10
|
Quote:
**EDIT** I forgot to include the errors . They're string function errors - nothing to do with the filesystem stuffCode:
gcc test2.c test2.c: In function ‘main’: test2.c:18: warning: incompatible implicit declaration of built-in function ‘strlen’ test2.c:19: warning: incompatible implicit declaration of built-in function ‘strncpy’
Last edited by rabidgnome229 : 02-23-08 at 02:05 AM. |
||||||||||||||
|
|
|
|
#4 (permalink) | ||||||||||||||
|
Miscelaneous
|
Quote:
__________________
|
||||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|