Hy,
please help me with the following program written in C which seems to not work in Visual C++.
#include "stdafx.h"
#include "string.h"
# include "process.h"
# include "malloc.h"
#define maxim 20
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fis;
int v=20;
float i=1.7;
char name[maxim];
char surname[maxim];
printf_s("name=",name);
scanf_s("%s",&name);
printf_s("surname",surname);
scanf_s("%s",&surname);
fis=fopen_s(fis,"C:\test","w");
fprintf (fis, "#Personal data#\n");
fprintf (fis, "name=%s\n",name);
fprintf (fis, "surname=%s\n",surname);
fprintf (fis, "age=%d\n",v);
fprintf (fis, "height=%.2f\n",i);
fprintf (fis, "#end#");
fclose (fis);
return 0;
}
What I need to change in order to make it work?
Sincerly,
[edit moved from comment]
Thank you Sir,
The programs looks now like that:
"
#include "stdafx.h"
#include "malloc.h"
#include <string.h>
#include <process.h>
#include <stdio.h>
#define maxim 20
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fis;
int v=20;
int i=17;
char name[maxim];
char surname[maxim];
printf_s("name=",name);
scanf_s("%s",&name);
printf_s("surname",surname);
scanf_s("%s",&surname);
errno_t errorCode =fopen_s(&fis,"C:\\test","w");
fprintf(fis, "#Personal datas#\n");
fprintf(fis, "name=%s\n",name);
fprintf(fis, "surname=%s\n",surname);
fprintf (fis, "ages""=%d\n",v);
fprintf (fis, "height=%d\n",i);
fprintf(fis, "#end#");
fclose(fis);
return 0;
}
"
But with the following errors:
"1>------ Build started: Project: ConsoleApplication45, Configuration: Debug Win32 ------
1> ConsoleApplication45.cpp
1>c:\users\marius\documents\visual studio 2012\projects\consoleapplication45\consoleapplication45\consoleapplication45.cpp(28): error C2001: newline in constant
1>c:\users\marius\documents\visual studio 2012\projects\consoleapplication45\consoleapplication45\consoleapplication45.cpp(29): error C2146: syntax error : missing ')' before identifier 'fprintf'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="
If I comment the lines with the errors, the programs craks after the name or surname
Below I have link with a print screen of the error: http://s9.postimage.org/sd4oudbyn/err_C.jpg
[/edit]