C语言问题,天真的想法

来源:百度知道 编辑:UC知道 时间:2024/05/04 12:28:18
我感觉这个问题有点天真:都是把下面的程序运行一次如果再次运行就不能再显示出来(这个程序都失效),如果能限次次数就更好..就有点像防盗版似的
#include <stdio.h>
#include <TIME.H>
#include <string.h>
int main( )
{
char c;
FILE *f;
char sy[20],sm[4],sd[4];
time_t nowtime;
struct tm *timeinfo;
int year,month,day;
time( &nowtime );
timeinfo = localtime( &nowtime );
year = timeinfo->tm_year + 1900;
month = timeinfo->tm_mon + 1;

day = timeinfo->tm_mday;
sprintf(sy, "%d ", year);
sprintf(sm, "%d ", month);
sprintf(sd, "%d \n", day);

strcat(sy,sm);
strcat(sy,sd);
f=fopen("C:\\1r.txt","w");
fclose(f);
f=fopen("C:\\1r.txt","at");
fprintf(f, "%s", "this result is:");
fprintf(f, "%s", sy);
fclose(f);

f=fopen("C:\\1r.txt","r");

想法不错,不过用户只有改变了你的配置文件,不久不行了么!

孩子,软件安装在我的机子上,那么再怎么防止盗版也防不住的,呵呵。

我也是个新手 但是我觉得可以在程序的目录下增加一个加密数据文件,程序的运行需要里面的允许数据,所以用户不能破解和删除,你要限制程序的使用次数就可以在那个加密数据文件中实现

你在文件 的一个地方记录一下,程序的每次启动都修改该数据,等到该数据到达一定程度之后,就不让该程序执行.