473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

converting from file pointer to character pointer

hi all,
i am studying engg,i have problem that ,how can i convet from the file pointer to character pointer or character array.in my project i cant use file pointer,i need to convert file pointer as a character pointer.please help me in this regard,

thank u advance
aswin
Jul 30 '07 #1
3 2948
weaknessforcats
9,208 Expert Mod 8TB
Do you have a code sample where you are stuck?
Jul 30 '07 #2
hai,

this is my code where i have stuck the thing is i cant use any FILE pointers in my project and iam in need of any alternative char pointer or char array.
The following part is the code i want to alter

Expand|Select|Wrap|Line Numbers
  1.  #ifdef _CHECK_BITS_
  2. FILE *fpe;
  3. #endif
  4.  TextureObjectLayer_enc(FILTER *wvtfilter, SOL_PARAMETERS *vm_param)
  5. {
  6.   FILE *bitfile;
  7.   int  texture_object_id=0;
  8. char fname[100];
  9.   int  texture_object_layer_shape =vm_param->sa_dwt;
  10. init_bit_packing_fp(bitfile,1);
  11.  if ((bitfile=fopen(fname,"wb"))==NULL)
  12.         errorHandler("Can't open file '%s' for writing.",fname);
  13. #ifdef _CHECK_BITS_
  14.  fpe=fopen("encode_bits","w");
  15. #endif
  16. }
  17.  
  18.  
  19. void init_bit_packing_fp(FILE *fp,int clearByte)
  20. {
  21.  
  22.     byte_count=0;
  23.     count=0;
  24.     bitfile=fp;
  25.     bytes_in_buffer=bitrate=huff_put_buffer=huff_put_bits=bit_buf=0;
  26.  
  27.     //clean byte pointer only when asked for
  28.     if(clearByte == 0)
  29.        fseek(bitfile,-(buffer_length-byte_ptr+((bit_num+1)/8)),SEEK_CUR);
  30.  
  31.  
  32.     buffer_length=byte_ptr=0;
  33.     bit_num=-1;
  34.  
  35. }
  36.  
Thanks in advance for your reply.
Jul 31 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
From what I can surmise, the problem is on this line:
fseek(bitfile,-(buffer_length-byte_ptr+((bit_num+1)/8)),SEEK_CUR);
your byte_ptr needs to be an int and not a pointer.

When working with fseek, you are always calculating an offset and that offset is always an interger value. That is, all of your calculations are relative to the beginning, current position , or end of the file. There is no addressing involved.
Jul 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable...
3
by: AMT2K5 | last post by:
Would it not be more efficient to take in a void pointer? int number = 30; fout.write((char *)(&number), sizeof(number));
4
by: Jamiil | last post by:
How do I get the length of a character pointer? TIA
14
by: sheroork | last post by:
Can anyone help me in getting to understand pointer to pointer with examples? Appritiate in advance. Sagar
2
by: Kavya | last post by:
Since Circle is-a Shape we are allowed to do this Circle *c = new Circle; Shape *s = c; //Works But we can't do this Circle **cc = &c; Shape **ss = cc; //Does not works
11
by: eagerlearner | last post by:
I know what is pointer, but I always blurred by character pointer to string. Can you tell me these accordingly ? Thanks. What is the difference ? char string = "abc"; // between this one and...
2
by: bipinskulkarni | last post by:
Hi, i have a field createdby with datatype GUID. In following query ,i encountered with the error "Conversion failed when converting from a character string to uniqueidentifier" select...
1
by: SnehaAgrawal | last post by:
Hi I get the error "Syntax error converting datetime from character string "for the following sql statement in Stored proc. SET @dynamicSQL =N'SELECT CUSTID,SHCodeLink FROM AccountMaster where...
1
by: lakshmishivakumar | last post by:
how to pass character pointer from tcl to c through interface file using swig?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.