pointer « pointer « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » pointer » pointer 

1. Did i set my file pointer wrong?    stackoverflow.com

#include "stdafx.h"
#include "string.h"
#include "stdio.h"
void CharReadWrite(FILE *fin);
FILE *fptr2;

int _tmain(int argc, _TCHAR* argv[])
{   

    char filename[]="ReadMe.txt";
    if (fopen_s( &fptr2, filename, "r" ) != 0 )
 ...

2. Creating own FILE* pointer in C?    stackoverflow.com

I had just a look at the stdio.h where I could find the FILE structure definition:

typedef struct  {
   int          ...

3. Retrieving the name of the file that is associated with a file pointer    stackoverflow.com

Assume I have a file pointer FILE* myfile. Is there a way to retrieve the name of the file where myfile is reading from or writing to?

4. Pointer to FILE nulling itself without being used at all    stackoverflow.com

in the following code when ran will produce a Segmentation Fault, due to a FILE* being passed to fclose which contains no address (NULL). I'm wondering why this is happening, the FILE* ...

5. Duplicating file pointers?    stackoverflow.com

Just a quick question: Is there a way to duplicate a file pointer (those returned by fopen()), similar to how dup() duplicates a file handlers returned by functions like open()? Basically, I ...

6. C File Operations: Check opened file pointer access mode    stackoverflow.com

A simple question: How do I check the access mode of an already opened file pointer? So say a function is passed an already opened FILE pointer:

    //Pseudo code
  ...

7. Is there a way to set file pointers equal to each other in C?    stackoverflow.com

For example, if I have

FILE *fp, *tfp;

fp = fopen (file, mode);

tfp = fp;
is this possible?

8. strcat giving unexpected result    stackoverflow.com

This is a very small portion of a large project... These are typedefs defined in standard header file for the project.

typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
typedef uint8_t  u_int8_t;
Now this is the actual ...

9. Can descriptors for sockets be converted to File Pointers?    stackoverflow.com

I got a descriptor for a TCP socket in the following manner :

int desc = accept(socket_descriptor, &client_address, &len)
Now from this descriptor desc I want to get a file pointer. ...

10. return file pointer to begginning    bytes.com

11. Given a file pointer is there any way to get the fill path to thefile    bytes.com

"parag_paul@hotmail.com"

12. file pointer reset of CArchive    bytes.com

13. Problems with FILE pointers    bytes.com

Hi everyone! I am currently experiencing some problems... My program crashes when i open a file which does exist. The problem seems to happen when two pointers point at the same file. Could it be the reason why my program's crashing? Paul. Thanks a lot. Hi,. Is the program crashing during opening the file or during any file operations when u ...

14. How to print File pointer    bytes.com

15. Help with File pointers in C    bytes.com

16. File pointer problem    bytes.com

Hi, I've been staring myself blind on the same little code now and I cant see the problem. The filepointer seems to not change when I open it in a function. I've written like this (a bit pseudo here): void func(FILE* file) { /* print addr of file (2)*/ file = fopen("thefile", "wb"); /* open as binary */ /* print addr ...

17. Reuse of File pointer    bytes.com

18. FILE pointer    bytes.com

I have made a simple program to read the contents of a file.The FILE pointer returns NULL at the very beginning eventhough the file is present.Now if I modify my program and use command line arguments instead, I get the desired output.Now after I have run this program with argv; and I shift back to the one without command line arguments ...

19. HELP :Decrementing the file pointer    cboard.cprogramming.com

I am writing a code that should do the following.. Count how many times a certain string occurs in the second column of a file for a range in the first column.. This is a simple version of my code :- Code: #include int main() { FILE *fptr1; int c[30]; int n; for(n = 0; n<=30;n++) {c[n]=0;} int x=0; int i=0; ...

20. File Pointers    cboard.cprogramming.com

21. Help with understanding file pointers    cboard.cprogramming.com

Hi all, I am relatively new at programming in C so forgive me if this question sound a bit idiotic. I have a problem regarding passing file pointers in a program I am writing. So my input is in the following format from a file: Code: 0 3 1 0 2 0 3 0 4 1 2 1 3 1 4 ...

22. file pointer as argument    cboard.cprogramming.com

I'm having trouble understanding this function, I know it reads a line and copies it to a string, but I don't know what arguments to use when calling it. I haven't met the file pointer before and don't quite know how it works. I'm guessing it needs to point to the string which is being read, but I want to read ...

23. file pointer    cboard.cprogramming.com

24. FILE pointer problem    cboard.cprogramming.com

#include #include #include int main() { FILE *fp1,*fpo; char s[20][100],ch; int i,j; fp1=fopen("pr31.c","w"); if(fp1==NULL) { printf("cannot open file"); } while(strlen(gets(s))>0) { fputs(s,fp1); fputs("\n",fp1); } printf("file closed\n\n"); fpo=fopen("pr32.c","w"); ch=fgetc(fp1); i=j=0; while(!feof(fp1)) { if(ch=='\n') { s[i][j]='\0'; i++; j=0; } else { s[i][j]=ch; j++; } ch=fgetc(fp1); } for(j=0;j

25. Inputting Data File Using Pointers    cboard.cprogramming.com

26. Passing FIle pointer as argt    cboard.cprogramming.com

27. freeing a file pointer without upsetting Valgrind    cboard.cprogramming.com

Code: ==32022== Invalid read of size 4 ==32022== at 0x40B11AD: (within /lib/tls/i686/cmov/libc-2.8.90.so) ==32022== by 0x40B1E7F: (within /lib/tls/i686/cmov/libc-2.8.90.so) ==32022== by 0x4072DE9: exit (in /lib/tls/i686/cmov/libc-2.8.90.so) ==32022== by 0x405A68C: (below main) (in /lib/tls/i686/cmov/libc-2.8.90.so) ==32022== Address 0x41a49f8 is 104 bytes inside a block of size 352 free'd ==32022== at 0x4024E5A: free (vg_replace_malloc.c:323) ==32022== by 0x804A3F6: outline_free (outline.c:324) ==32022== by 0x8049369: main (main.c:234) ==32022== Invalid read ...

28. Problem with file handling (pointers)    cboard.cprogramming.com

#include #include main (int argc, char *argv[]) { FILE *out0,*out1,*out2,*out3,*out4; double alfa,omega,k0,c; char filtemp [128]; sprintf(filtemp,"a%3.1lfW%3.1lfk%3.1lfBA%3.1lfsignature.dat",alfa,omega,k0,c); if(!(out0=fopen(filtemp,"w"))) { printf("Can't open %s file!",filtemp); exit(0); } sprintf(filtemp,"a%3.1lfW%3.1lfk%3.1lfBA%3.1lfpotential.dat",alfa,omega,k0,c); if(!(out1=fopen(filtemp,"w"))) { printf("Can't open %s file!",filtemp); exit(0); } sprintf(filtemp,"a%3.1lfW%3.1lfk%3.1lfBA%3.1lfderivative.dat",alfa,omega,k0,c); if(!(out2=fopen(filtemp,"w"))) { printf("Can't open %s file!",filtemp); exit(0); } sprintf(filtemp,"a%3.1lfW%3.1lfk%3.1lfBA%3.1lfresults.dat",alfa,omega,k0,c); if(!(out3=fopen(filtemp,"w"))) { printf("Can't open %s file!",filtemp); exit(0); } fprintf(out0,"test"); fprintf(out1,"test"); fprintf(out2,"test"); fprintf(out3,"test"); fclose(out0); fclose(out1); fclose(out2); fclose(out3); ...

29. How to move file pointer using gotoxy    cboard.cprogramming.com

30. returning file pointer    cboard.cprogramming.com

31. trouble with file pointers...    cboard.cprogramming.com

teyla:~ quasigreat$ cat carpool.txt 4 75 11.0 2 50 9.0 5 95 15.5 2 60 4.5 4 35 4.3 6 70 20.7 0 0 0 teyla:~ quasigreat$ ~quasigreat/a.out Please enter the minimum efficiency> 25 teyla:~ quasigreat$ cat effic.txt CARPOOLS MEETING MINIMUM PASSENGER EFFICIENCY OF 25 PASSENGER KM / L Passengers Weekly Commute Gasoline Efficiency Weekly (km) Consumption(L) (pass km / L) ...

32. Help with file pointer    cboard.cprogramming.com

I have the code below to open a file, append some text and then display the contents of that file on the screen. I am new to programming and trying to learn on my own for the company I work for. Any help is greatly appreciated. I was expecting to have this statement - if (fptr == NULL); be false but ...

33. Methods and file pointers    cboard.cprogramming.com

/* * remove the extra & at fp * * fileScan does return any value therefore while can't work checking if it is the EOF * population, squareMilege, pollution, crime, expense, highways are not the same that in the function; * those are a copy */ while(fileScan(fp, cityName, population, squareMileage, pollution, crime, expense, highways) != EOF) // get next char from ...

34. A File Pointer Question    cboard.cprogramming.com

FILE objects are usually created by a call to either fopen or tmpfile, which both return a reference to one of these objects. The content of a FILE object is not meant to be read from outside the functions of the cstdio library; In fact, its main purpose is to be referenced as an argument in all stream-involving functions of this ...

35. question on file pointers    cboard.cprogramming.com

#include int main ( void ) { char str [ 80 ]; FILE * input, * east; if ( ( input = fopen ( "east", "r" ) ) == NULL ) { printf ( "Cannot open file\n" ); exit ( 1 ); } printf ("Enter in the firstname, lastname teamname"); printf (", jersey number, points and game in that order"); ...

36. Please help connect file pointer    cboard.cprogramming.com

#include #include int main(void) { FILE *sfp; unsigned int score; sfp = fopen("C:\\scores.txt","r"); if ( sfp != (FILE *) NULL ) { /* Put a loop around this bit */ fscanf(sfp, "%u", &score); printf("score %u\n",score); /* end of loop */ fclose(sfp); } else { /* find out what the error is ! */ printf("open failed with errno=%d\n", errno); } ...

37. FILE pointer as arguement?    cboard.cprogramming.com

long time; /* know C? */ Unprecedented performance: Nothing ever ran this slow before. Any sufficiently advanced bug is indistinguishable from a feature. Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31. The best way to accelerate an IBM is at 9.8 m/s/s. recursion (re - cur' - zhun) n. 1. (see recursion)

38. fin fout, file pointer question    cboard.cprogramming.com

39. single File Pointer to Multiple Files    cboard.cprogramming.com

40. EOF file pointer    cboard.cprogramming.com

41. File pointer lists file twice?    cboard.cprogramming.com

42. passing pointers to other files    cboard.cprogramming.com

FILE *readfile; int lexInit(char* filename) { readfile = fopen(filename,"r"); if(readfile == 0) { printf("\nfile could not be opened\n\n"); } else { printf("\n File opened\n"); } return 0; } int lex(Lexeme *lexeme_pointer) { char ch; ch = readchar(); lexeme_pointer->type = 'funny'; printf("type = %s",&lexeme_pointer.type); return 0; } ///readchar int readchar() { char ch; ch = fgetc(readfile); return ch; } int pushback() { ...

43. FILE pointer null checking problem    cboard.cprogramming.com

44. help, updating file via file pointer    cboard.cprogramming.com

45. Question on pointer & files    cboard.cprogramming.com

Hi every one, I am trying to write a function that deletes a whitespace that seperates the last name followed by a ',' from the first name Initial. It is part of a compression program that we have to write. I am having trouble understanding pointers. So if anyone could help me, that would be great. Here the function I have ...

46. File pointers and paths to files    cboard.cprogramming.com

I am trying to open a file and save the a pointer to that file in *out_fp Keep getting a syntax error at around this point in my code, know it is prob. easily fixed but just haven't been able to get it. I have also added the code before this part as it could be the problem also where i ...

47. PS: I gotta bad feeling about the file pointers!    cboard.cprogramming.com

wazzup?...i got 4 functions including main (see below)...main gives the option of calling engine() or find()...these 2 call funk() for the computation and printinf of results...find() works fine when it call funk()...so funk() is working alright...engine() with funk() gives a Segmentation Fault core dumped!...engine() is this tinee tiny lil' function with 10 lines of code...can't seem to figure out whats' wrong...tried ...

48. getting filename from a file pointer    cboard.cprogramming.com

Shadow, you've lost me ! Are we talking about the same thing?!! Read the original post.... it is a request for a function to obtain the name of the file opened by any given file pointer. So, if we did this in main(): >FILE *fp = fopen ("test.txt", "r"); Then passed fp to another function like this: >myfunc(fp); How would myfunc ...

49. Adding new records to a file using a pointer    cboard.cprogramming.com

My program is to get 5 fields, including one called 'position' that shows the sequential position of the record in the file. If I have 5 records in the file, *.txt, the last position in that file should be 4. If i want to put a new record in it should be position 5. After I use f_open to open the ...

50. GCC compile error coz of file pointer    cboard.cprogramming.com

51. file pointer as an argument?    cboard.cprogramming.com

52. file pointer    cboard.cprogramming.com

If you had 2 integer's (int a and int b) to copy the contents from one integer to another you'd do - a = b; If you have two pointers(int* a and int* b) to copy the contents from one to the other you'd do - a = b; If this was a pointer to a pointer then the statement would ...

53. FILE pointers    cboard.cprogramming.com

54. File parsing (pointer, loops)    forums.devshed.com

Hi, I'm new to C and after 4 hours, I can't figure out how to parse this file. The ugly code: Code: // Scan input data while (fscanf(inputFile, "%i %s %i %i\n", &data.week, &data.name, &data.units, &data.price) != EOF) { if (data.week == 0) { totalWeek0 += data.price; } if (data.week == 1) { totalWeek1 += data.price; } if (data.week == 2) ...

56. File Pointers    forums.devshed.com

i still think you don't need a pointer to pointer, a pointer itself should do it because at some points you say &fp, you send the address of your pointer.. which doesn't really make sence because you give him the address of the address that you need.. you can just give him the address that he needs by sending fp

57. Help with File pointers in C    forums.devshed.com

58. rs232 FILE pointer oscilloscope    forums.devshed.com

I want to establish connection with oscilloscope via rs232. How could i do it with FILE pointer? I`m using BorlandC 3.1 File is defined as a structure in : typedef struct{ short level; unsigned flags; char fd; unsigned char hold; short bsize; unsigned char *buffer, *curp; unsigned istemp; short token; } FILE; } Thanks, Ginrare.

59. File pointer & random generator    daniweb.com

#include #include #include #include void makeUpper (char *s); void menu (void); int numberGenerator(int min, int max); char characterGenerator(void); main() { int i = 0, i2 = 0, j = 0, wordcount = 0, cancel = 0, run = 1, posx = 0, posy = 0, pass = 0, direction = 0; char temp[50], words[10][16], puzzle[25][70], condition; do ...

60. passing file pointer around    daniweb.com

61. Problem in FILE pointers    daniweb.com

#include #include #include #include #include #include #include #include #include #include int main() { FILE *logs; logs = fopen("/home/aniroot/logs/log.txt","a"); if(logs = NULL) { printf("fopen failed ... There would be no log for this session!!!"); } int sockfd,newfd; int err; struct addrinfo *res,*p,hints; struct sockaddr_storage their_addr; socklen_t addr_size; int yes=1; char ip[INET6_ADDRSTRLEN]; memset(&hints,0,sizeof(hints)); hints.ai_family=AF_UNSPEC; hints.ai_flags=AI_PASSIVE; hints.ai_socktype=SOCK_STREAM; printf("Server is open for listening on port ...

62. file pointer and arguments to main.    daniweb.com

63. File pointers    daniweb.com

#include #include int main(int argc, char *argv[]) { char file_name[100]; /*declare char arrays to hold file name and text*/ char file_text[500]; char c; /*char to hold text characters */ int counter1, counter2; FILE *input_file, *input1_file, *output_file; /*declaration of file pointers */ printf("\nenter the name & extension of text file to create:"); scanf("%s", &file_name); printf("\nenter the text to be reversed:"); ...

64. Pointers errors and file handling    daniweb.com

#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "estructuras.h" #include "funciones.h" #include "menus.h" #define num 999 /* Localizado en menus.h */ void menuprincipal(cli *); //void menucliente(cli *); //void menuproductos(); //void ...

65. dynamically creating multiple File pointers    daniweb.com

#include #include int main() { FILE **fp; char filename[20]; int i; fp = malloc( sizeof(FILE *) * 10); if( fp != NULL ) { for(i=0; i<10; i++) { sprintf(filename, "%s%d.txt", "file",i+1); if( ( fp[i] = fopen(filename, "a+") ) == NULL ) { printf("Error: File \"%s\" cannot be opened\n", filename); continue; } fprintf( fp[i], "%s", "Hello There"); fclose(fp[i]); } } ...

66. Do we have to free a FILE pointer?    daniweb.com

67. File Pointer in C    daniweb.com

I am using filepointer in C. when I compile the code and run it for the first time the filepointer works fine and logs are written into log files. But during next hits there is an inconsistency in logs getting written. sometimes getting written and someother times not written. But during all those times the file pointer returns a valid integer. ...

68. file pointer problem    daniweb.com

/* 1. Get array dimensions and print array. 2. Create array based on total. 3. Fill AND sort array. 4. Print sorted array. */ #include #include #define FILENAME "data.txt" #define MODE "r" int get_dim(FILE *); int *make_array(int ); void fill_array(FILE *, int *, int ); void insertion(int *, int ); int main(void) { FILE *fp = fopen(FILENAME, MODE); int ...

69. file pointer increament    daniweb.com

70. Is there a difference between the put and get pointer of a fstream?    codeproject.com

Thanks a lot for digging that up! I think that explains the problem allthough i have to admit i didn't get this in detail. So does this mean i'll have to manage the file positions myself ( e.g. with temporary variables) lets say for the simple task of reading a value from a file just written to it?

71. File pointers    tek-tips.com

I asked an almost identical question in the tek-tips pascal forum. The general opinion seemed to be that this (allocating a file to two file structure variables) was unnecessary and probably undesirable; how it behaves might even vary with how the operating system handles files (for instance file-control-block or file-handle approaches may vary in how they behave)Of course, that was Pascal, ...

72. Simple question: File Pointers    tek-tips.com

Howdy,Thanks for helping a new programmer, I sincerely appreciate it. I am trying to copy character string information stored in a file pointer to another pointer.Should I initialize the pointer likechar newPtr[90000]? (yea the file pointer being copied to it is big!)And what statement do I use to transfer data from the two pointers?*newPtr = *inputPtr; ?Note: ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.