热门标签 | HotTags
当前位置:  开发笔记 > 运维 > 正文

使用C语言实现vector动态数组的实例分享

vector是指能够存放任意类型的动态数组,而C语言中并没有面向对象的C++那样内置vector类,所以我们接下来就来看一下使用C语言实现vector动态数组的实例,需要的朋友可以参考下

下面是做项目时实现的一个动态数组,先后加入了好几个之后的项目,下面晒下代码。

头文件:

# ifndef __CVECTOR_H__ 
# define __CVECTOR_H__ 
# define MIN_LEN 256 
# define CVEFAILED -1 
# define CVESUCCESS 0 
# define CVEPUSHBACK 1 
# define CVEPOPBACK 2 
# define CVEINSERT  3 
# define CVERM    4 
# define EXPANED_VAL 1 
# define REDUSED_VAL 2 
 
typedef void *citerator; 
typedef struct _cvector *cvector; 
 
# ifdef _cplusplus 
# define EXTERN_ extern "C" 
# else 
# define EXTERN_ extern 
# endif 
 
EXTERN_ cvector  cvector_create  (const size_t size              ); 
EXTERN_ void   cvector_destroy (const cvector cv              ); 
EXTERN_ size_t  cvector_length  (const cvector cv              ); 
EXTERN_ int    cvector_pushback (const cvector cv, void *memb        ); 
EXTERN_ int    cvector_popback (const cvector cv, void *memb        ); 
EXTERN_ size_t  cvector_iter_at (const cvector cv, citerator iter      ); 
EXTERN_ int    cvector_iter_val (const cvector cv, citerator iter, void *memb); 
EXTERN_ citerator cvector_begin  (const cvector cv              ); 
EXTERN_ citerator cvector_end   (const cvector cv              ); 
EXTERN_ citerator cvector_next   (const cvector cv, citerator iter      ); 
EXTERN_ int    cvector_val_at  (const cvector cv, size_t index, void *memb ); 
EXTERN_ int    cvector_insert  (const cvector cv, citerator iter, void *memb); 
EXTERN_ int    cvector_insert_at(const cvector cv, size_t index, void *memb ); 
EXTERN_ int    cvector_rm    (const cvector cv, citerator iter      ); 
EXTERN_ int    cvector_rm_at  (const cvector cv, size_t index       );  
 
/* for test */ 
EXTERN_ void   cv_info     (const cvector cv              ); 
EXTERN_ void   cv_print     (const cvector cv              ); 
#endif /* EOF file cvector.h */ 


C文件:

# include  
# include  
# include  
# include  
# define MIN_LEN 256 
# define CVEFAILED -1 
# define CVESUCCESS 0 
# define CVEPUSHBACK 1 
# define CVEPOPBACK 2 
# define CVEINSERT  3 
# define CVERM    4 
# define EXPANED_VAL 1 
# define REDUSED_VAL 2 
 
typedef void *citerator; 
typedef struct _cvector  
{    
  void *cv_pdata; 
  size_t cv_len, cv_tot_len, cv_size; 
} *cvector; 
 
# define CWARNING_ITER(cv, iter, file, func, line) \ 
  do {\ 
    if ((cvector_begin(cv) > iter) || (cvector_end(cv) <= iter)) {\ 
      fprintf(stderr, "var(" #iter ") warng out of range, "\ 
          "at file:%s func:%s line:%d!!/n", file, func, line);\ 
      return CVEFAILED;\ 
    }\ 
  } while (0) 
 
# ifdef _cplusplus 
# define EXTERN_ extern "C" 
# else 
# define EXTERN_ extern 
# endif 
 
EXTERN_ cvector  cvector_create  (const size_t size              ); 
EXTERN_ void   cvector_destroy (const cvector cv              ); 
EXTERN_ size_t  cvector_length  (const cvector cv              ); 
EXTERN_ int    cvector_pushback (const cvector cv, void *memb        ); 
EXTERN_ int    cvector_popback (const cvector cv, void *memb        ); 
EXTERN_ size_t  cvector_iter_at (const cvector cv, citerator iter      ); 
EXTERN_ int    cvector_iter_val (const cvector cv, citerator iter, void *memb); 
EXTERN_ citerator cvector_begin  (const cvector cv              ); 
EXTERN_ citerator cvector_end   (const cvector cv              ); 
EXTERN_ citerator cvector_next   (const cvector cv, citerator iter      ); 
EXTERN_ int    cvector_val_at  (const cvector cv, size_t index, void *memb ); 
EXTERN_ int    cvector_insert  (const cvector cv, citerator iter, void *memb); 
EXTERN_ int    cvector_insert_at(const cvector cv, size_t index, void *memb ); 
EXTERN_ int    cvector_rm    (const cvector cv, citerator iter      ); 
EXTERN_ int    cvector_rm_at  (const cvector cv, size_t index       ); 
 
/* for test */ 
EXTERN_ void   cv_info     (const cvector cv              ); 
EXTERN_ void   cv_print     (const cvector cv              ); 
 
cvector cvector_create(const size_t size) 
{ 
  cvector cv = (cvector)malloc(sizeof (struct _cvector)); 
 
  if (!cv) return NULL; 
 
  cv->cv_pdata = malloc(MIN_LEN * size); 
 
  if (!cv->cv_pdata)  
  { 
    free(cv); 
    return NULL; 
  } 
 
  cv->cv_size = size; 
  cv->cv_tot_len = MIN_LEN; 
  cv->cv_len = 0; 
 
  return cv; 
} 
 
void cvector_destroy(const cvector cv) 
{ 
  free(cv->cv_pdata); 
  free(cv); 
  return; 
} 
 
size_t cvector_length(const cvector cv) 
{ 
  return cv->cv_len; 
} 
 
int cvector_pushback(const cvector cv, void *memb) 
{ 
  if (cv->cv_len >= cv->cv_tot_len)  
  { 
    void *pd_sav = cv->cv_pdata; 
    cv->cv_tot_len <<= EXPANED_VAL; 
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size); 
 
    if (!cv->cv_pdata)  
    { 
      cv->cv_pdata = pd_sav; 
      cv->cv_tot_len >>= EXPANED_VAL; 
      return CVEPUSHBACK; 
    } 
  } 
 
  memcpy(cv->cv_pdata + cv->cv_len * cv->cv_size, memb, cv->cv_size); 
  cv->cv_len++; 
 
  return CVESUCCESS; 
} 
 
int cvector_popback(const cvector cv, void *memb) 
{ 
  if (cv->cv_len <= 0) return CVEPOPBACK; 
 
  cv->cv_len--; 
  memcpy(memb, cv->cv_pdata + cv->cv_len * cv->cv_size, cv->cv_size); 
 
  if ((cv->cv_tot_len >= (MIN_LEN <cv_len <= (cv->cv_tot_len >> REDUSED_VAL)))  
  { 
    void *pd_sav = cv->cv_pdata; 
    cv->cv_tot_len >>= EXPANED_VAL; 
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size); 
 
    if (!cv->cv_pdata)  
    { 
      cv->cv_tot_len <<= EXPANED_VAL; 
      cv->cv_pdata = pd_sav; 
      return CVEPOPBACK; 
    } 
  } 
 
  return CVESUCCESS; 
} 
 
size_t cvector_iter_at(const cvector cv, citerator iter) 
{ 
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__); 
  return (iter - cv->cv_pdata) / cv->cv_size; 
} 
 
int cvector_iter_val(const cvector cv, citerator iter, void *memb) 
{ 
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__); 
  memcpy(memb, iter, cv->cv_size); 
  return 0; 
} 
 
citerator cvector_begin(const cvector cv) 
{ 
  return cv->cv_pdata; 
} 
 
citerator cvector_end(const cvector cv) 
{ 
  return cv->cv_pdata + (cv->cv_size * cv->cv_len); 
} 
 
static inline void cvmemove_foreward(const cvector cv, void *from, void *to) 
{ 
  size_t size = cv->cv_size; 
  void *p; 
  for (p = to; p >= from; p -= size) memcpy(p + size, p, size); 
  return; 
} 
 
static inline void cvmemove_backward(const cvector cv, void *from, void *to) 
{ 
  memcpy(from, from + cv->cv_size, to - from); 
  return; 
} 
 
int cvector_insert(const cvector cv, citerator iter, void *memb) 
{ 
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__); 
 
  if (cv->cv_len >= cv->cv_tot_len)  
  { 
    void *pd_sav = cv->cv_pdata; 
    cv->cv_tot_len <<= EXPANED_VAL; 
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size); 
 
    if (!cv->cv_pdata)  
    { 
      cv->cv_pdata = pd_sav; 
      cv->cv_tot_len >>= EXPANED_VAL; 
      return CVEINSERT; 
    } 
  } 
 
  cvmemove_foreward(cv, iter, cv->cv_pdata + cv->cv_len * cv->cv_size); 
  memcpy(iter, memb, cv->cv_size); 
  cv->cv_len++; 
 
  return CVESUCCESS; 
} 
 
int cvector_insert_at(const cvector cv, size_t index, void *memb) 
{ 
  citerator iter; 
 
  if (index >= cv->cv_tot_len)  
  { 
    cv->cv_len = index + 1; 
    while (cv->cv_len >= cv->cv_tot_len) cv->cv_tot_len <<= EXPANED_VAL; 
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size); 
    iter = cv->cv_pdata + cv->cv_size * index; 
    memcpy(iter, memb, cv->cv_size); 
  } 
  else  
  { 
    iter = cv->cv_pdata + cv->cv_size * index; 
    cvector_insert(cv, iter, memb); 
  } 
 
  return 0; 
} 
 
citerator cvector_next(const cvector cv, citerator iter) 
{ 
  return iter + cv->cv_size; 
} 
 
int cvector_val(const cvector cv, citerator iter, void *memb) 
{ 
  memcpy(memb, iter, cv->cv_size); 
  return 0; 
} 
 
int cvector_val_at(const cvector cv, size_t index, void *memb) 
{ 
  memcpy(memb, cv->cv_pdata + index * cv->cv_size, cv->cv_size); 
  return 0; 
} 
 
int cvector_rm(const cvector cv, citerator iter) 
{ 
  citerator from; 
  citerator end; 
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__); 
  from = iter; 
  end = cvector_end(cv); 
  memcpy(from, from + cv->cv_size, end - from); 
  cv->cv_len--; 
 
  if ((cv->cv_tot_len >= (MIN_LEN <cv_len <= (cv->cv_tot_len >> REDUSED_VAL)))  
  { 
    void *pd_sav = cv->cv_pdata; 
    cv->cv_tot_len >>= EXPANED_VAL; 
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size); 
 
    if (!cv->cv_pdata)  
    { 
      cv->cv_tot_len <<= EXPANED_VAL; 
      cv->cv_pdata = pd_sav; 
      return CVERM; 
    } 
  } 
 
  return CVESUCCESS; 
} 
 
int cvector_rm_at(const cvector cv, size_t index) 
{ 
  citerator iter; 
  iter = cv->cv_pdata + cv->cv_size * index; 
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__); 
  return cvector_rm(cv, iter); 
} 
 
void cv_info(const cvector cv) 
{ 
  printf("/n/ntot :%s : %d/n", __func__, cv->cv_tot_len); 
  printf("len :%s : %d/n",   __func__, cv->cv_len); 
  printf("size:%s : %d/n/n",  __func__, cv->cv_size); 
  return; 
} 
 
void cv_print(const cvector cv) 
{ 
  int num; 
  citerator iter; 
 
  if (cvector_length(cv) == 0) 
    fprintf(stderr, "file:%s func:%s line:%d error, null length cvector!!/n", __FILE__, __func__, __LINE__); 
 
  for (iter = cvector_begin(cv);  
      iter != cvector_end(cv); 
      iter = cvector_next(cv, iter))  
  { 
    cvector_iter_val(cv, iter, &num); 
    printf("var:%d at:%d/n", num, cvector_iter_at(cv, iter)); 
  } 
 
  return; 
} 

改进版
上面那份代码是在Linux下写的,如果是在Windows的Visul C++环境下编译似乎会出些问题,所以特别做了个改进版:
下面是更新后的代码:

cvector.h

# ifndef __CVECTOR_H__ 
# define __CVECTOR_H__ 
 
# include   
# include   
# include   
 
# define MIN_LEN 256 
# define CVEFAILED -1 
# define CVESUCCESS 0 
# define CVEPUSHBACK 1 
# define CVEPOPBACK 2 
# define CVEINSERT  3 
# define CVERM    4 
# define EXPANED_VAL 1 
# define REDUSED_VAL 2 
 
typedef void *citerator; 
typedef struct _cvector *cvector; 
 
# ifdef __cplusplus 
extern "C" { 
# endif 
 
  cvector  cvector_create  (const size_t size              ); 
  void   cvector_destroy (const cvector cv              ); 
  size_t  cvector_length  (const cvector cv              ); 
  int    cvector_pushback (const cvector cv, void *memb        ); 
  int    cvector_popback (const cvector cv, void *memb        ); 
  size_t  cvector_iter_at (const cvector cv, citerator iter      ); 
  int    cvector_iter_val (const cvector cv, citerator iter, void *memb); 
  citerator cvector_begin  (const cvector cv              ); 
  citerator cvector_end   (const cvector cv              ); 
  citerator cvector_next   (const cvector cv, citerator iter      ); 
  int    cvector_val_at  (const cvector cv, size_t index, void *memb ); 
  int    cvector_insert  (const cvector cv, citerator iter, void *memb); 
  int    cvector_insert_at(const cvector cv, size_t index, void *memb ); 
  int    cvector_rm    (const cvector cv, citerator iter      ); 
  int    cvector_rm_at  (const cvector cv, size_t index       ); 
 
  /* for test */ 
  void   cv_info     (const cvector cv              ); 
  void   cv_print     (const cvector cv              ); 
 
# ifdef __cplusplus 
} 
# endif 
 
#endif /* EOF file cvector.h */ 

cvector.c

#include "cvector.h" 
 
#ifndef __gnu_linux__ 
#define __func__ "unknown" 
#define inline __forceinline 
#endif 
 
# define CWARNING_ITER(cv, iter, file, func, line) \ 
  do {\ 
  if ((cvector_begin(cv) > iter) || (cvector_end(cv) <= iter)) {\ 
  fprintf(stderr, "var(" #iter ") warng out of range, "\ 
  "at file:%s func:%s line:%d!!\n", file, func, line);\ 
  return CVEFAILED;\ 
  }\ 
  } while (0) 
 
struct _cvector 
{ 
  void *cv_pdata; 
  size_t cv_len, cv_tot_len, cv_size; 
}; 
 
cvector cvector_create(const size_t size) 
{ 
  cvector cv = (cvector)malloc(sizeof (struct _cvector)); 
 
  if (!cv) return NULL; 
 
  cv->cv_pdata = malloc(MIN_LEN * size); 
 
  if (!cv->cv_pdata) 
  { 
    free(cv); 
    return NULL; 
  } 
 
  cv->cv_size = size; 
  cv->cv_tot_len = MIN_LEN; 
  cv->cv_len = 0; 
 
  return cv; 
}  
 
void cvector_destroy(const cvector cv)  
{  
  free(cv->cv_pdata);  
  free(cv);  
  return;  
}  
 
size_t cvector_length(const cvector cv)  
{  
  return cv->cv_len;  
}  
 
int cvector_pushback(const cvector cv, void *memb)  
{  
  if (cv->cv_len >= cv->cv_tot_len)   
  {  
    void *pd_sav = cv->cv_pdata;  
    cv->cv_tot_len <<= EXPANED_VAL;  
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size);  
 
    if (!cv->cv_pdata)   
    {  
      cv->cv_pdata = pd_sav;  
      cv->cv_tot_len >>= EXPANED_VAL;  
      return CVEPUSHBACK;  
    }  
  }  
 
  memcpy((char *)cv->cv_pdata + cv->cv_len * cv->cv_size, memb, cv->cv_size);  
  cv->cv_len++;  
 
  return CVESUCCESS;  
}  
 
int cvector_popback(const cvector cv, void *memb)  
{  
  if (cv->cv_len <= 0) return CVEPOPBACK;  
 
  cv->cv_len--;  
  memcpy(memb, (char *)cv->cv_pdata + cv->cv_len * cv->cv_size, cv->cv_size);  
 
  if ((cv->cv_tot_len >= (MIN_LEN <cv_len <= (cv->cv_tot_len >> REDUSED_VAL)))   
  {  
    void *pd_sav = cv->cv_pdata;  
    cv->cv_tot_len >>= EXPANED_VAL;  
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size);  
 
    if (!cv->cv_pdata)   
    {  
      cv->cv_tot_len <<= EXPANED_VAL;  
      cv->cv_pdata = pd_sav;  
      return CVEPOPBACK;  
    }  
  }  
 
  return CVESUCCESS;  
}  
 
size_t cvector_iter_at(const cvector cv, citerator iter)  
{  
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__);  
  return ((char *)iter - (char *)cv->cv_pdata) / cv->cv_size;  
}  
 
int cvector_iter_val(const cvector cv, citerator iter, void *memb)  
{  
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__);  
  memcpy(memb, iter, cv->cv_size);  
  return 0;  
}  
 
citerator cvector_begin(const cvector cv)  
{  
  return cv->cv_pdata;  
}  
 
citerator cvector_end(const cvector cv)  
{  
  return (char *)cv->cv_pdata + (cv->cv_size * cv->cv_len);  
}  
 
static inline void cvmemove_foreward(const cvector cv, void *from, void *to)  
{  
  size_t size = cv->cv_size;  
  char *p;  
  for (p = (char *)to; p >= (char *)from; p -= size) memcpy(p + size, p, size);  
  return;  
}  
 
static inline void cvmemove_backward(const cvector cv, void *from, void *to)  
{  
  memcpy(from, (char *)from + cv->cv_size, (char *)to - (char *)from);  
  return;  
}  
 
int cvector_insert(const cvector cv, citerator iter, void *memb)  
{  
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__);  
 
  if (cv->cv_len >= cv->cv_tot_len)   
  {  
    void *pd_sav = cv->cv_pdata;  
    cv->cv_tot_len <<= EXPANED_VAL;  
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size);  
 
    if (!cv->cv_pdata)   
    {  
      cv->cv_pdata = pd_sav;  
      cv->cv_tot_len >>= EXPANED_VAL;  
      return CVEINSERT;  
    }  
  }  
 
  cvmemove_foreward(cv, iter, (char *)cv->cv_pdata + cv->cv_len * cv->cv_size);  
  memcpy(iter, memb, cv->cv_size);  
  cv->cv_len++;  
 
  return CVESUCCESS;  
}  
 
int cvector_insert_at(const cvector cv, size_t index, void *memb)  
{  
  citerator iter;  
 
  if (index >= cv->cv_tot_len)   
  {  
    cv->cv_len = index + 1;  
    while (cv->cv_len >= cv->cv_tot_len) cv->cv_tot_len <<= EXPANED_VAL;  
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size);  
    iter = (char *)cv->cv_pdata + cv->cv_size * index;  
    memcpy(iter, memb, cv->cv_size);  
  }  
  else   
  {  
    iter = (char *)cv->cv_pdata + cv->cv_size * index;  
    cvector_insert(cv, iter, memb);  
  }  
 
  return 0;  
}  
 
citerator cvector_next(const cvector cv, citerator iter)  
{  
  return (char *)iter + cv->cv_size;  
}  
 
int cvector_val(const cvector cv, citerator iter, void *memb)  
{  
  memcpy(memb, iter, cv->cv_size);  
  return 0;  
}  
 
int cvector_val_at(const cvector cv, size_t index, void *memb)  
{  
  memcpy(memb, (char *)cv->cv_pdata + index * cv->cv_size, cv->cv_size);  
  return 0;  
}  
 
int cvector_rm(const cvector cv, citerator iter)  
{  
  citerator from;  
  citerator end;  
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__);  
  from = iter;  
  end = cvector_end(cv);  
  memcpy(from, (char *)from + cv->cv_size, (char *)end - (char *)from);  
  cv->cv_len--;  
 
  if ((cv->cv_tot_len >= (MIN_LEN <cv_len <= (cv->cv_tot_len >> REDUSED_VAL)))   
  {  
    void *pd_sav = cv->cv_pdata;  
    cv->cv_tot_len >>= EXPANED_VAL;  
    cv->cv_pdata = realloc(cv->cv_pdata, cv->cv_tot_len * cv->cv_size);  
 
    if (!cv->cv_pdata)   
    {  
      cv->cv_tot_len <<= EXPANED_VAL;  
      cv->cv_pdata = pd_sav;  
      return CVERM;  
    }  
  }  
 
  return CVESUCCESS;  
}  
 
int cvector_rm_at(const cvector cv, size_t index)  
{  
  citerator iter;  
  iter = (char *)cv->cv_pdata + cv->cv_size * index;  
  CWARNING_ITER(cv, iter, __FILE__, __func__, __LINE__);  
  return cvector_rm(cv, iter);  
}  
 
void cv_info(const cvector cv)  
{  
  printf("\n\ntot :%s : %d\n", __func__, cv->cv_tot_len);  
  printf("len :%s : %d\n",   __func__, cv->cv_len);  
  printf("size:%s : %d\n\n",  __func__, cv->cv_size);  
  return;  
}  
 
void cv_print(const cvector cv)  
{  
  int num;  
  citerator iter;  
 
  if (cvector_length(cv) == 0)  
    fprintf(stderr, "file:%s func:%s line:%d error, null length cvector!!\n", __FILE__, __func__, __LINE__);  
 
  for (iter = cvector_begin(cv);   
    iter != cvector_end(cv);  
    iter = cvector_next(cv, iter))   
  {  
    cvector_iter_val(cv, iter, &num);  
    printf("var:%d at:%d\n", num, cvector_iter_at(cv, iter));  
  }  
 
  return;  
}  

main.cpp

#include "cvector.h" 
 
int main() 
{ 
  int i = 1; 
  cvector cv = cvector_create(sizeof(int)); 
  cvector_pushback(cv, &i); 
  cvector_pushback(cv, &i); 
  cvector_pushback(cv, &i); 
  cvector_pushback(cv, &i); 
  cv_print(cv); 
  cvector_destroy(cv); 
  return 0; 
} 


推荐阅读
  • 优化联通光猫DNS服务器设置
    本文详细介绍了如何为联通光猫配置DNS服务器地址,以提高网络解析效率和访问体验。通过智能线路解析功能,域名解析可以根据访问者的IP来源和类型进行差异化处理,从而实现更优的网络性能。 ... [详细]
  • 本文详细分析了JSP(JavaServer Pages)技术的主要优点和缺点,帮助开发者更好地理解其适用场景及潜在挑战。JSP作为一种服务器端技术,广泛应用于Web开发中。 ... [详细]
  • PyCharm下载与安装指南
    本文详细介绍如何从官方渠道下载并安装PyCharm集成开发环境(IDE),涵盖Windows、macOS和Linux系统,同时提供详细的安装步骤及配置建议。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 在计算机技术的学习道路上,51CTO学院以其专业性和专注度给我留下了深刻印象。从2012年接触计算机到2014年开始系统学习网络技术和安全领域,51CTO学院始终是我信赖的学习平台。 ... [详细]
  • Linux 系统启动故障排除指南:MBR 和 GRUB 问题
    本文详细介绍了 Linux 系统启动过程中常见的 MBR 扇区和 GRUB 引导程序故障及其解决方案,涵盖从备份、模拟故障到恢复的具体步骤。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 解决Linux系统中pygraphviz安装问题
    本文探讨了在Linux环境下安装pygraphviz时遇到的常见问题,并提供了详细的解决方案和最佳实践。 ... [详细]
  • 本文介绍了一款用于自动化部署 Linux 服务的 Bash 脚本。该脚本不仅涵盖了基本的文件复制和目录创建,还处理了系统服务的配置和启动,确保在多种 Linux 发行版上都能顺利运行。 ... [详细]
  • CMake跨平台开发实践
    本文介绍如何使用CMake支持不同平台的代码编译。通过一个简单的示例,我们将展示如何编写CMakeLists.txt以适应Linux和Windows平台,并实现跨平台的函数调用。 ... [详细]
  • Windows服务与数据库交互问题解析
    本文探讨了在Windows 10(64位)环境下开发的Windows服务,旨在定期向本地MS SQL Server (v.11)插入记录。尽管服务已成功安装并运行,但记录并未正确插入。我们将详细分析可能的原因及解决方案。 ... [详细]
  • 深入理解 Oracle 存储函数:计算员工年收入
    本文介绍如何使用 Oracle 存储函数查询特定员工的年收入。我们将详细解释存储函数的创建过程,并提供完整的代码示例。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 在 Windows 10 中,F1 至 F12 键默认设置为快捷功能键。本文将介绍几种有效方法来禁用这些快捷键,并恢复其标准功能键的作用。请注意,部分笔记本电脑的快捷键可能无法完全关闭。 ... [详细]
  • c# – UWP:BrightnessOverride StartOverride逻辑 ... [详细]
author-avatar
爱飞扬无限_316
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有