Hi,
I am a new bee to Visual C++, I have some problem.
This is my main program
--------------------------
----------
----------
----------
----------
----------
----------
--
#include "stdafx.h"
#include "parse.h"
int main(int argc, char* argv[])
{
char first[100],second[100];
first[0] = '\0',second[0]='\0';
//second = new char[10];
printf("Enter the string\n");
scanf("%s",first);
printf("The length of the string %s is %d\n",second,strlen(second
));
printf("The concatenated string is %s\n",concatenateN(first,6
));
return 0;
}
--------------------------
----------
----------
----------
----------
----------
----------
--
the declaration of concatenateN function is present in the include file parse.h
parse.h
--------------------------
----------
----------
----------
-------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
char *concatenateN(char *,int );
--------------------------
----------
----------
----------
--------
the definition of the function is in parse.c
parse.c
--------------------------
----------
----------
----------
------
#include "parse.h"
char *concatenateN(char *str,int n)
{
char *result = new char[strlen(str)*n+1];
result[0] = '\0';
for(int i=0;i<n;i++)
result = strcat(result,str);
return result;
}
--------------------------
----------
----------
----------
------
When I compile this function I am getting the error:
parse.c(15) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
Then I have included the file stdafx.h in parse.c, which changes the parse.c to
--------------------------
----------
----------
----------
-----
#include "parse.h"
char *concatenateN(char *str,int n)
{
char *result = new char[strlen(str)*n+1];
result[0] = '\0';
for(int i=0;i<n;i++)
result = strcat(result,str);
return result;
}
#include <stdafx.h>
--------------------------
----------
----------
----------
-----
Now it is giving the error:
parse.c(14) : fatal error C1853: 'Debug/robots_parse.pch' is not a precompiled header file created with this compiler
Error executing cl.exe.
I searched in MSDN help, but am not able to understand it.
Thanks,
Dp
Start Free Trial