⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointstr.cpp

📁 a simple code for using pointer in data structure
💻 CPP
字号:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<fstream.h>
main()
{ int k,in,out,sechnum,count;
  char name[500][25];
  char *ptr[500],*temp;
  fstream f;
//  ifstream  infile;
  //ofstream outfile;
 // clrscr();
  cout<<"how many names do tou want to list?";
  cin>>k;
  cout<<"input the list of names "<<endl;
  for(count=0;count<k;count++)
    {
   cout<<"enter name of number "<<count+1<<":";
   cin>>name[count][25];}
   //cin.get();//for read and dicard end of line char
   //if(!name[count][0])
  // break;
  //ptr[count++]=name[count];
  //}
  cout<<"enter the number of name for searching for";
  cin>>sechnum;
    /*for(out=0;out<count-1;out++)
   for(in=out+1;in<count;in++)
    if((strcmp(ptr[out],ptr[in]))>0){
     temp=ptr[in];
     ptr[in]=ptr[out];
     ptr[out]=temp;
   }cout<<"<<the sorted list is:>>"<<endl;
    for(out=0;out<k;out++){
     cout<<"name"<<out+1<<"is"<<ptr[out];
     cout<<endl;                }*/
   f.open("stdlist.dat",ios::in|ios::in|ios::app);
  for(out=0;out<k;out++){
    f.write(name[out],25);}
    f.seekg(sechnum,ios::beg);
    f.read(name[sechnum],25);
    //cout<<name<<endl;
    f.close();
    cout<<name<<endl;
    getch();
    return 0;
    }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -