|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
fast way to save data in C
hey guys,
i programed a little webcounter system in C using fastCGI and MySQL. It works fine but i dont log too much data so its ok. Now I am working on version 2 and i am looking for another way to save the data. i think there should be something faster then MySQL because i dont need it to be relational and i think using mysql i waste a lot of performance. do u have any idea what i could use? |
|
#2
|
|||
|
|||
|
fopen() ?
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
||||
|
||||
|
low level file access is the faster, but there is a learning curve on it,
if u are using linux/unix use unistd.h and the fucntion size_t write(int fildes, const void * but, size_t nbytes); //causes the first nbytes from buf to be written to the file associated with the file descriptor fildes read is size_t read(int fildes, void * buf, size_t nbytes); and open is int open(const char* path, int oflags); //where oflags are the bitwise OR of mandatory file access mode (i.e readonly, write only, reading and writing) using these is considerably faster than useing the higher level fstream or FILE*
__________________
microsofts butterfly is their way off telling u their systems have a **** load of buggs Advocating Linux Guide Lesbian Linux Great & Practical Computer Books like the links? |
|
#4
|
|||
|
|||
|
Just use the basic stdio file operations. They're portable and quite easy.
#include <stdio.h> int main() { FILE* fcount; int count=0; fcount = fopen("counter.dat", "r"); if (fcount) { fscanf(fcount, "%d", &count); fclose(fcount); } count++; printf("%d visitors", count); fcount = fopen("counter.dat", "w"); if (fcount) { fprintf(fcount, "%d", count); fclose(fcount); } else { printf("Nuts, I can't open the data file.\n"); } return 0; }
__________________
Clay Dowling Lazarus Notes Articles and commentary on web development http://www.lazarusid.com/notes/ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > fast way to save data in C |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|