   C question
  I am trying to do one thing, but i always get an error and I don't know how to get rid of it. Here's my code:int main(){...char fname[512];}...if(scanf("%128s",&tel)){printf("\nFilename: ");scanf("%128s",&fname);if(fname) {FILE *out = fopen(&fname,"wb+"); ...   }...}I get this error:error C2664: 'fopen' : cannot convert parameter 1 from 'char (*)[512]' to 'const char *'How to solve it?Thanks,Nebo   
  you're passing a pointer to an array when you only really need a pointer to the first element of the array. Convinently enough an array name decays into a pointer to first member if used alone.FILE *out = fopen(&fname,"wb+"); should be:FILE *out = fopen(fname,"wb+"); ;  Yeh, you're right! It works now, but it saves it as "fname" without extension. How to set it to save it as "fname.adr"?   ;  just put:strcat( fname, ".adr");after the scanf.   ;  I got an error:error C2065: 'strcat' : undeclared identifierI tried to include strings.h but then i got this error:fatal error C1083: Cannot open include file: 'strings.h': No such file or directoryWhat to do?   ;#include <string.h>is what you do :)   ;  Thank you very much! :D   ;Quote:Original post by vnebojsaThank you very much! :DGlad to help :) happy coding.   ;  I have 2 more questions:1. When I load saved file, it loads only first row, if file has three rows, it will load only first one. How to set it to load all rows, not only first?Code:if (chc1 == 2){FILE *in;char buf[100];printf("\nFilename: ");scanf("%128s",&ffname);strcat(ffname, ".adr");in = fopen(ffname,"r");if(!in){printf("\nPogreska: File \"%s\"",ffname);printf(" nije pronaden!\n\n");goto start;} fgets(buf,sizeof(buf),in);fclose(in);printf("\n%s\n",buf);goto start;}2. Is it possible to do next (commented text):Code:FILE *in;char buf[100]; // list all existing files with .adr extension in that folderprintf("\nFilename: ");scanf("%128s",&ffname);;if( in = fopen(ffname, "r")){while( !feof( in)){fgets( buf, sizeof(buf), in);printf("%s\n", buf);}   fclose(in);}should display the whole file.As for listing all .adr files in a given directory that's quite easy todo but if you don't use a good support library it's quite platform dependant, so tell me what platform you're running on and maybe I can help you with that to :)   