c - C99 - Why can't I use a variable-length char array in Xcode 6? -


A command line tool project is going to Xcode 6, and everything works very well except a small issue Is: I can not because find a value assigning a value to a variable-length array for my life! For example, consider the following code:

  #include & lt; String.h & gt; Int main () {int len ​​= 10; Four letters [lane]; Strcpy (str, "hello"); Printf ("% s", str); }  

It compiles precisely, but when I debug it, the array is never assigned to! If I set a breakpoint on line 7, press the Run button and hover over str , it only shows that name with an arrow near it, which does not show anything when expanded !

Correct me if I am wrong but I believe this is a completely valid C99 code which I am writing here ... then what does it give? I did not take any advantage of both the GNU99 compiler (default) and the C99 compiler.

MTIA: -)

EDIT: OK I'm confused and maybe even have a PO. Some people here (because I have earned at least 3 minimum votes on this question), then let me clarify some things.

I'm actually writing a libcurl app to upload MacOS Xiosmith files to a web server on HTTP at the end I "upload [destination url] [file or directory 1] [file or directory 2] ... [file or directory en] "I want to be able to type something in the terminal, and want to automatically upload my program [destination url] files and directories for invoked path CWD or full Can be relative.

The problem in my uploadDirectory function, as shown here:

  Zero upload directory (curl * hnd, structure curl_ httppost * post , Structure curl_ httppost * postEnd, char * path, const char * url) {DIR * dir = opendir (path); If (dir == NULL) {printf ("failed on \ nopendir path \"% s \ ", path); perror (zero);} other {struct dirent * file; while ((file = readdir (dir))! = NULL) {// Skip the current directory and root directory files (! Strcmp (file-> d_name, ".") ||! Strcmp (file-> d_name, "..")) Continue ; If (file-> d_type == DT_REG) {// file is an actual file; upload it // it is an abusive code character file [strollon (path) + strlen (file-> d_name) + 2 ]; Strcpy (file path, path); dome (file path, "/"); dome (file path, file-> d_name); int res = uploadFile (HD, POS Printf ("% d", res);} If (file-> d_type == DT_DIR) {// file is a directory; recurse it on / for this section to abbreviate I have been omitted}} closed (DIR);}}  

I know that I can define the problem filePath with a huge continuous size But how big is the bigger? What is the maximum length of the file path in OS X? Etc, etc. ... so I would like to make it the right size.

If you have increased the height of this post and have reached here, then thank you very much for being patient! I basically tried to describe this problem in brief, but I was clearly creating nothing but confusion, so I apologize for that: -)

  int n; Scanf ("% d", & amp; n); Four one [n];  

A A VLA is not an array VLA shown in your example.

VLA is supported in C99. If you are not able to try the output

  printf ("% s \ n", test);  

Besides this, your code looks good.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -