pralaydesai
asked on
i want to read from file and assing to variable
Hi all,
I want to read from file and assing to variable in int format. For that i wrote bellow mentioned code.
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
int main(void)
{
clrscr();
FILE *stream;
char string[] = "Th";
char *ch="10";
int p=0;
stream = fopen("DUMMY.TXT", "r");
fseek(stream, 0, SEEK_SET);
fgets(ch, strlen(string), stream);
p=atoi(ch);
cout<<p;
fclose(stream);
getch();
return 0;
}
it's working fine individually. but when i put it in another file out of which i am making dll then when i am
running it it gives sharing acess violation in fgets function.
Can any one help me is there any other logic when making dll of it?
Thanks in advace,
Regards,
Pralay
I want to read from file and assing to variable in int format. For that i wrote bellow mentioned code.
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
int main(void)
{
clrscr();
FILE *stream;
char string[] = "Th";
char *ch="10";
int p=0;
stream = fopen("DUMMY.TXT", "r");
fseek(stream, 0, SEEK_SET);
fgets(ch, strlen(string), stream);
p=atoi(ch);
cout<<p;
fclose(stream);
getch();
return 0;
}
it's working fine individually. but when i put it in another file out of which i am making dll then when i am
running it it gives sharing acess violation in fgets function.
Can any one help me is there any other logic when making dll of it?
Thanks in advace,
Regards,
Pralay
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi,
It work bit not fully.
i know i have to say it works and accept the answer but if it works fully then is it wrong?
One more request,
I want to read a specific lin's specific character is it possible?
Regards,
Pralay
It work bit not fully.
i know i have to say it works and accept the answer but if it works fully then is it wrong?
One more request,
I want to read a specific lin's specific character is it possible?
Regards,
Pralay
I think I will decline to answer until you've addressed the issue raised by Gula.
> It work bit not fully.
And my psychic ability tells me exactly what you did wrong.
Post your latest code and new question!
There's no point you offering points if you've no intention of completing the process.
> i know i have to say it works and accept the answer but if it works fully then is it wrong?
If the answer helps you past whatever problem you have then it's an acceptable answer in my opinion.
> It work bit not fully.
And my psychic ability tells me exactly what you did wrong.
Post your latest code and new question!
There's no point you offering points if you've no intention of completing the process.
> i know i have to say it works and accept the answer but if it works fully then is it wrong?
If the answer helps you past whatever problem you have then it's an acceptable answer in my opinion.
ASKER
Thanks ,
It took bit time for understand what you post. Initially what i thought was in wrong direction.
Regards,
Pralay
It took bit time for understand what you post. Initially what i thought was in wrong direction.
Regards,
Pralay
thank you