
我也没在数据库中存过图片,上边是在其他地方看到的,你可以尝试百度一下上边的关键词,看看有没有具体的过程或者例子,能帮你的就这些了。
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int file_size(char* filename)//获取文件名为filename的文件大小。
{
FILE *fp = fopen(filename, "rb")//打开文件。
int size
if(fp == NULL) // 打开文件失败
return -1
fseek(fp, 0, SEEK_END)//定位文件指针到文件尾。
size=ftell(fp)//获取文件指针偏移量,即文件大小。
fclose(fp)//关闭文件。
return size
}
int main ()
{
int size=0
size=file_size("qw")
printf("%d\n",size)
FILE * pFile,*qw
char *buffer=(char*)malloc(sizeof(char)*size)
qw =fopen("qw","r")
pFile = fopen ( "qwe" , "wb" )
printf("%d==\n",pFile)
printf("%d\n",size)
fread(buffer,1,size,qw)
fwrite (buffer , sizeof(byte), size , pFile )
fclose (pFile)
rename("qwe","Groot.jpg")
return 0
}
扩展资料:
c语言读取TXT文件:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LINE 1024
int main()
{
char buf[MAX_LINE] /*缓冲区*/
FILE *fp /*文件指针*/
int len /*行字符个数*/
if((fp = fopen("test.txt","r")) == NULL)
{
perror("fail to read")
exit (1)
}
while(fgets(buf,MAX_LINE,fp) != NULL)
{
len = strlen(buf)
buf[len-1] = '\0' /*去掉换行符*/
printf("%s %d \n",buf,len - 1)
}
return 0
}
// stdafx.h中包含#include <atlimage.h>
// 定义
CImage m_image
// 你的图片句柄HBITMAP m_hBmp
m_image.Attach( m_hBmp)
// 要保存的文件名称。全路径
// 保存格式会根据 strPathName文件名的后缀自动判断,
// .JPG, .BMP, .png 等
m_image.Save( strPathName)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)