写了一个小程序,随机对字符串进行排序的,为什么输出的会是乱码呢?哪里错了,望指教……
#include <iostream>
#include <time.h>
#include<stdlib.h>
#include <string>
using namespace std;
char* getnick()
{
int i,j;
char a[]="abcdefg",b;
srand((unsigned)time(NULL));
for(i=0;i<7;i++)
{
j = rand()%7;
b = a[i];
a[i] = a[j];
a[j] = b;
}
return a;
}
void main()
{
char *p;
int i=0;
p=getnick();
puts(p);
system("pause");
}
securecrt乱码怎么办