We are trying to send several emails via C language on a centos 6.2 platform. Below are the codes.
I added and left char *filename = ""; the I get error as sh: TEST: No such file or directory sh: TEST: No such file or directory sh: TEST: No such file or directory. If I add a message to it give me another error warning: incompatible implicit declaration of built-in function âsprintfâ
How to solve this issue?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define cknull(x) if((x)==NULL) {perror(""); exit(EXIT_FAILURE);}
#define cknltz(x) if((x)<0) {perror(""); exit(EXIT_FAILURE);}
#define LIST_LEN 4
void main()
{
char tmp[256]={0x0};
char fpBuffer[512]={0x0};
char email_list[LIST_LEN][256]={ {"****@gmail.com"},
{"****@gmail.com"},
{"***@gmail.com"},
{0x0}};
int i=0;
char *filename = "";
for(i=0;*email_list[i]>0x0;i++)
{
cknull(strcpy(tmp, email_list[i]));
cknltz(sprintf (fpBuffer,
"/usr/bin/mailx -s '%s %s' %s < %s",
"Please Review:",
filename,
tmp,
filename));
if(system (fpBuffer)==(-1))
{
perror("email failure");
exit(EXIT_FAILURE);
}
}
}