Link to home
Start Free TrialLog in
Avatar of pralaydesai
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
ASKER CERTIFIED SOLUTION
Avatar of Kryp
Kryp
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
pralaydesai, you have asked 14 questions, and have accepted none of them ... If you got your solutions ,  go through your questions and accept the answers that give solution to your question, othervise they remain in the system as unsolved
thank you
Avatar of pralaydesai
pralaydesai

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
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.
Thanks ,

          It took bit time for understand what you post. Initially what i thought was in wrong direction.

Regards,
Pralay