Still don't see a variable called str in your code, or any calls to assert. This must be coming from a call to a library funciton. A quick Google search came up with a few sites pointing at fprintf. Run your code through the debugger line by line, and look for which fprintf call (or other function call) is causing this. Then, via the debugger, see which variable of yours is NULL when it shouldn't be. There are some issues I noticed though:
Code:
//Variables used by multiple parts of the program are declared here
char userdir[100]; //user directory variable
DIR *serverdir; //declares serverdir as directory
FILE *sfp;//declares sfp as file pointer for server media list
FILE *cfp;//declares cfp as file pointer for client media list
struct dirent *ent;//declares ent as a struct
char clientname[1024];//declare clientname as a string
char servername[1024];//declare servername as string
int i=0;//this counts how many entries there are in server file list
int j=0;//this counts how many time the comparison loop is used
char copyarray[1024];
Variables used by multiple parts of the program is no excuse for globals. Global variables are evil, and should be avoided at all costs. Be a good boy/girl and declare them in the appropriate function, and pass them around as needed.
Code:
int welcome()//this section displays the applications welcome message
{//start function
printf("--------------------------------------------------------------------------------");//dsplay text
printf(" Welcome to the ICE Systems file sycronisation SERVER application \n");//dsplay text
printf("--------------------------------------------------------------------------------");//dsplay text
printf("\n");//new line
return 0;//nothing is returned back to main
}//end of the welcome message procidure
Don't comment every line, everybody knows that a { and } are for the start/end of a function or block of code and that printf displays text. Only comment things that aren't obvious. Also, if you don't return anything that will be used, don't return anything at all. Also, if you don't want to take any parameters, explicitly make the param list void:
Code:
int createfilelist()//this section creates a list of the servers media directory
{//start function
...
sfp=fopen("c:\\ICE Systems\\serverlist.txt", "w+");//opens the file to store media directory
Check the value of fopen, and stop processing if you can't open the file. You don't need a "+" in the mode since you never read from that file.
Why are you using a global i, especially when you don't initialize it right before? Change your code to call something else first that puts a non-zero value in i and you're screwed.
Code:
return 0;//nothing is returned back to main
}// end of function that created media directory
Make the function take and return void, since you don't use the return value and there are no params.
Code:
sfp=fopen("c:\\ICE Systems\\serverlist.txt", "r");//points server file pointer to server file list
cfp=fopen("c:\\ICE Systems\\clientlist.txt", "r");//points client file pointer to client file list
cpl=fopen("c:\\ICE Stystems\\copylist.txt", "a+");//points copy list file pointer to copy list
stemp=fopen("c:\\ICE Systems\\stemp.txt", "a+");
ctemp=fopen("c:\\ICE Ststems\\ctemp.txt", "a+");
Again, check return values and print errors if you can't open them all. Don't open with a "+" in the mode unless you are definitely reading AND writing.
Code:
fgets(sll1, 1024, sfp);
fgets(cll1, 1024, cfp);
You should use fgets(sll1, sizeof(sll1), sfp). That way, if you change the size of sll1, you won't have to change your fgets call, or any memsets, etc.
Code:
sllarray[a] = slfirstline[1024];
...
cllarray[b] = clfirstline[1024];
slfirstline has 1024 elements. That means that valid indexes are 0..1023. 1024 is out of bounds. You can't assign entire arrays that way, if that's what you're trying to do.
Code:
while(c<a, c++)
{
fprintf(stemp, "%s", sllarray[c]);
}
while(d<b, d++)
{
fprintf(ctemp, "%s", cllarray[d]);
}
I suspect those fprintf calls are the source of your assert error. cllarray[d] is a char, %s wants a char *, i.e. a string. I think you really need to brush up on arrays and strings. We have a couple tutorials here and here, and you should Google for some more, and do some simpler practice exercises until you have that down pat.
Code:
copyline[1024] = sll1[1024];
//-delete first line of server list and make old second line new first line
Again, your array indexes are out of bounds. I don't know how this is supposed to delete anything.
Code:
memset(sll1, ' ', 1024);//sets all entries in array sll1[1024] to a blank space
memset(cll1, ' ', 1024);//sets all entries in array cll1[1024] to a blank space
fprintf(cpl, "%s", copyline);//prints copyline to the copy list
memset(copyline, ' ', 1024);//sets all entries in array copyline[1024] to a blank space
Again, memset(sll1, ' ', sizeof(sll1). Also, since you seem to be using all these arrays as strings, you should "empty" them by setting them to the null character, '\0', with memset(sll1, 0, sizeof(sll1)), or more simply sll1[0] = '\0'.
Code:
int sendfiles()
{
...
ftp = fopen("c:\\ftp.txt", "w+");
cpylst = fopen("c:\\Ice Systems\\copylist.txt", "r");
char *cpyarray[1024];
For the last bloody time, check the return values! Also, don't use a "+" in the mode of ftp file! You never read from that file in this function.