file c

posted on 13 Nov 2009 21:01 by mheevun

http://www.cs.bu.edu/teaching/c/file-io/intro/

http://www.mycplus.com/tutorials/c-programming-tutorials/file-handling/

http://www.daniweb.com/forums/thread106413.html

http://www.exforsys.com/forum/c-and-c/94870-how-open-image-file.html

http://in.answers.yahoo.com/question/index?qid=20080827235900AAeN2hC

ชัดเจน

http://www.cprogramming.com/tutorial/cfileio.html

http://www.exforsys.com/tutorials/c-language/file-management-in-c.html

example

http://webspace.webring.com/people/xi/isafamily/ex2/

edit @ 19 Nov 2009 17:33:06 by Mheevun

http://www.adhocconference.com/papers/2003/Downs.GIFDecoderFinal.pdf

http://msdn.microsoft.com/en-us/library/aa970565.aspx

http://msdn.microsoft.com/en-us/library/ms771452.aspx

edit @ 19 Nov 2009 17:46:06 by Mheevun

http://svn.effbot.org/public/tags/pil-1.1.2/encode.c

http://webspace.webring.com/people/xi/isafamily/ex2/gif-lzw-enc.htm

edit @ 19 Nov 2009 17:47:27 by Mheevun

matalab

posted on 05 Nov 2009 10:00 by mheevun

matlab tutorial

http://www.docstoc.com/docs/2140819/MATLAB-TUTORIAL

 example---------------------------------------------------------------------------

close all
m = 75;
c = 10.5;
g = 9.81;
v0 = 0;
tend = 12;
tstart = 0;

dt = 1;
vcurrent = v0;
v = vcurrent;
for t=tstart:dt:tend
    vfuture = (vcurrent+g*dt)/(1+c/m*dt);
    v = [v vfuture];
    vcurrent = vfuture;
end;

v
t=tstart:dt:tend+dt
plot(t,v);
hold on
vexact=g*m/c*(1-exp(-c/m*t));
plot(t,vexact,'red');

err = (vexact-v)./vexact*100;
figure(2);
plot(t,err);
xlabel('time(s)');
ylabel('Velocity Error(m/s)');
%---------------------------------------------

dt = 0.1;
vcurrent = v0;
v = vcurrent;
for t=tstart:dt:tend
    vfuture = (vcurrent+g*dt)/(1+c/m*dt);
    v = [v vfuture];
    vcurrent = vfuture;
end;

v
t=tstart:dt:tend+dt
figure(1);
plot(t,v,'black');
hold on
vexact=g*m/c*(1-exp(-c/m*t));
plot(t,vexact,'red');

err = (vexact-v)./vexact*100;
figure(2);
hold on
plot(t,err,'m');
xlabel('time(s)');
ylabel('Velocity Error(m/s)');

-------------------------------------------------------------------------------------------

ผิด

%can
close all
m=68.1;   % mass
c=12.5;   % drag coeff
g=9.81;   % gravitational
v0 = 0;   % current velocity
tend = 12;
tstart = 0;

vcurrent = v0;
dt = 1; % time step
va1 = vcurrent; %first approx value
for t=tstart:dt:tend  
    vfuture = (vcurrent+g*dt)/(1+c/m*dt);
    va1 = [va1 vfuture];
    vcurrent = vfuture;
end;

t=tstart:dt:tend+dt;
plot(t,va1,'red');

% second case for dt = 0.5 s

vcurrent=v0;
dt = 0.5; % time step
va2 = vcurrent; % second approx value
for t=tstart:dt:tend  
    vfuture = (vcurrent+g*dt)/(1+c/m*dt);
    va2 = [va2 vfuture];
    vcurrent = vfuture;
end;

hold on
figure(1);
t=tstart:dt:tend+dt;
plot(t,va2,'black');

va1=va1(1:13);
va2=va2(1:2:26);
ea=(va2-va1)./va2*100;

figure(2);
plot(t,ea);

edit @ 10 Nov 2009 08:57:46 by Mheevun

LAB socket

posted on 04 Nov 2009 15:58 by mheevun

 http://fivedots.coe.psu.ac.th/~cj/241-302/

SOCKETPAIR

 socketpair(AF_UNIX, SOCK_STREAM, 0, sv)  

- AF.UNIX = connection with local if internet is INET.UNIX

-SOCK_STREAM = type of socket if SOCK_STREAM is TCP else SOCK_DATAGRAM is udp

-0 =

-sv =

 

ssize_t size

 

size = send(sv[1], buf, strlen(buf), 0)

int send(int sockfd, const void *msg, int len, int flags);

sockfd is the socket descriptor you want to send data to (whether it's the one returned by socket() or the one you got with accept().) msg is a pointer to the data you want to send,
 

 

size = recv(s, buf, sizeof(buf), 0)

int recv(int sockfd, void *buf, int len, unsigned int flags);

      sockfd is the socket descriptor to read from, buf is the buffer to read the information into,
len is the maximum length of the buffer, and flags can again be set to 0. (See the recv()
man page for flag information.)
    recv() returns the number of bytes actually read into the buffer, or -1 on error (with
errno set, accordingly.)
    Wait! recv() can return 0. This can mean only one thing: the remote side has closed the
connection on you! A return value of 0 is recv()'s way of letting you know this has occurred