程序不太行 2013-09-28 15:01 采纳率: 100%
浏览 4184
已采纳

C++编程问题:系统找不到指定文件(确定是程序的问题)

提示系统找不到指定文件,确定是程序的问题,求大神啊!

// 链表.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "windows.h"
#include "conio.h"

//创建POINT的同义
typedef POINT datatype;

typedef struct node
{
datatype data;
struct node *next;
}nodetype;

//声明数据操作
nodetype *creat(nodetype *L);
void InsertElem(nodetype *L,int i,int x,int y);
void DeleteElem(nodetype *L,int i);
void Clear(nodetype *L);
nodetype *GetElem(nodetype *L,int i);
int Length( nodetype *L );

//声明画布的操作
void DrawLine(nodetype *L,HDC hdc);
void clearWindow(HWND hwnd);

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

HWND hwnd = GetConsoleWindow();
HDC hdc = GetDC( hwnd );
::SelectObject( hdc, GetStockObject( DC_PEN ));
::SetDCPenColor( hdc, RGB( 0,0,255 ));

nodetype *list;
Clear(list);
nodetype *creat(list);

DrawLine( list, hdc);
getchar();
clearWindow(hwnd);
getchar();
DrawLine( list, hdc);

int i,x,y;
getchar();
printf("请输入要插入点的id,点坐标:");
scanf("\n%d\t%d\t%d",&i,&x,&y);
InsertElem( list,i ,x,y);
getchar();
clearWindow(hwnd);
getchar();
DrawLine( list, hdc);

getchar();
printf("请输入要删除的点的id:");
scanf("\n%d",&i);
DeleteElem(list, i );
getchar();
clearWindow(hwnd);
getchar();
DrawLine( list, hdc);

return 0;
}

void clearWindow( HWND hwnd )
{
InvalidateRect( hwnd, NULL, true );
UpdateWindow( hwnd );
system("cls");
}
nodetype creat(nodetype *L)
{
FILE
fp = fopen( "D:\shapes.txt", "r");
if( fp)
{
char line[200];
fgets( line,200, fp);
//printf( "%s", line);

    int shapeCount;
    fscanf( fp, "%d\n",&shapeCount);
    //printf( "shapeCount = %d \n", shapeCount );
    //getch();

    int shapeType, id , vertexCount;

    for( int i = 0 ; i < shapeCount; ++i)

        fscanf( fp, "%d,%d,%d\n",&shapeType, &id , &vertexCount);
        //printf( "shapeType = %d ,id = %d, vertexCount = %d \n", shapeType,id, vertexCount );
        //getch();

nodetype *s,*t; 
nodetype *h=(nodetype*)malloc(sizeof(nodetype));
for(int i=0;i<shapeCount;++i)
{
    nodetype* s=(nodetype*)malloc(sizeof(nodetype));
    fscanf( fp, "%d,%d\n",s->data.x,s->data.y);
    s->next=NULL;t->next=s;t=s;
}return h;
    }

}

void DrawLine(nodetype *L,HDC hdc)
{
int x,y;
char label[20];
POINT pt;
nodetype *p;
p=GetElem(L,0);
p->data.x=pt.x;
p->data.y=pt.y;
sprintf( label, "%d,%d", pt.x, pt.y );
TextOutA( hdc, pt.x,pt.y, label, strlen( label ));
//printf( "%d,%d\n" , pt.x, pt.y );

MoveToEx( hdc,pt.x, pt.y,0 );
for ( int i = 2; i <= Length( L ) ; ++i )
{
    p=GetElem(L, i );
    p->data.x=pt.x;
    p->data.y=pt.y;
    LineTo( hdc, pt.x,pt.y );
    sprintf( label, "%d,%d", pt.x, pt.y );
    TextOutA( hdc, pt.x,pt.y, label, strlen( label ));
    //printf( "%d,%d\n" , pt.x, pt.y );
}

}

void InsertElem(nodetype *L,int i,int x,int y)
{

nodetype *e,*p,*q;

p=GetElem(L, i-1);
q=GetElem(L, i);
e->data.x=x;
e->data.y=y;;
e->next=q;p->next=e;
}

nodetype *GetElem(nodetype *L,int i)
{nodetype *p=L;
int j=0;

while((p->next!=NULL)&&(j {
p=p->next;j++;
}
if(i==j)return p;
else return NULL;
}

void DeleteElem(nodetype *L,int i)
{
nodetype *p,*r;

p=GetElem(L, i-1);
if( (p!=NULL) && (p->next!=NULL))
{
nodetype * r = p->next; p->next = r->next; free(r);
}
else printf("error\n");
}

  • 写回答

2条回答 默认 最新

  • Eleven 2015-01-04 09:42
    关注

    FILE fp = fopen( "D:\shapes.txt", "r");
    --》
    FILE fp = fopen( "D:\shapes.txt", "r");

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)