小人物

精益求精
posts - 3, comments - 0, trackbacks - 0, articles - 0

2009年10月21日

#include<iostream.h>
#include<string.h>
void main()
{
 char tt[]={'t','e','f'};
 int f=10;
 /*cout<<strlen(tt)<<endl;
 cout<<&tt<<endl;
 cout<<&tt+1<<endl;
 cout<<sizeof(((&tt+1)-&tt))<<endl;
 cout<<sizeof(int)<<endl;
 cout<<sizeof(char)<<endl;
 for(int i=0;i<strlen(tt);i++)
   cout<<&tt[i]<<"\n";
    cout<<endl;
    for(char i=0;i<strlen(tt);i++)
   cout<<(&tt)+i<<" "<<*((&tt)+i)<<endl;
    cout<<endl; */
 char *p;
 cout<<"未进行指向前指针p的地址:"<<&p<<endl;
 int *x;
 cout<<"未进行指向前指针x的地址:"<<&x<<endl;
 x=&f;
 p=tt;  //将tt中的内容复制到p的内容中去 ,而不是将tt的地址复制到p的内容中去(应该是一种其他的映射机制而不是复制----这样太浪费计算机的速度)
 cout<<"字符串的地址:"<<&tt<<endl; //显示的字符串的地址
 cout<<"进行指向后指针p的地址:"<<&p<<endl;
 cout<<"显示指针p的内容:"<<p<<endl; //显示的是这个指针指向的内容
 cout<<"指针x的内容:"<<x<<endl;
 cout<<"f的地址:"<<&f<<endl; //显示f的地址
 cout<<"进行指向后指针x的地址:"<<&x<<endl;// 显示指针x的地址  通过这个可以说明指针在没有被指向的时候是有地址的
 p[0]='q';
 cout<<&p<<endl;
 cout<<*p<<endl;
}//通过这个例子知道指针在声明的时候就有一个地址;
 //指针指向的必须是地址(这个是根据指针前面的类型符号来判断的--好像是)
 //指针的"内容"就是指向的值,比如 x指针的内容就是f的内容;这样做的目的是为了减少建立临时变量的麻烦 1 指针===矢量

posted @ 2009-10-21 16:59 军 阅读(340) | 评论 (0)编辑 收藏

2009年10月20日

#include<iostream.h>
void main()
{
 char t[]={"china"};
 cout<<"我们国家的名字:"<<t<<endl;
 int length=10;
 for(int i=0;i<6;i++)
 {
  cout<<t[i]<<" ";
 }
 cout<<endl;
 for(int i=0;i<6;i++)
 {
  cout<<&t[i]<<"\n";
 }
 cout<<endl;
 cout<<"该字符串的长度是:"<<sizeof(t)/sizeof(char)<<endl;
 int s=100;
 cout<<"s的值是:"<<s<<endl;
 cout<<"s的地址是:"<<&s<<endl;
 //cout<<"t的地址是:"<<&t[0]<<endl;//存在一个问题:就是在这里使用&t[0]输出地址的时候输出的是整个字符串,而不是地址??好奇怪
   cout<<"t的地址是:"<<&t<<endl;                              //疑惑的第二个地方:怎么使用&输出每个元素的地址呢?? 
}

posted @ 2009-10-20 14:00 军 阅读(222) | 评论 (0)编辑 收藏

以下为在asp中增加一个sql server2000用户函数,

并为建立一个数据库,给他dbo的权限 ' 注意:sql server的验证方式不要选仅为windows方式, ' 允许远程sql server连接 ' 该函数已通过测试'

' 参数:StrLoginName:新增登录名,StrPwd:登录名的密码,StrDBName:新建数据库名 ' 函数内局部变量说明:StrServer:服务器所在机器名(本机为local),StrUid:sql管理员, ' StrSaPwd:sql管理员密码。以上三个变量应根据你的情况设置
' 该函数主要调用系统存储过程来实现的
' 注意:本函数没有容错处理,如出现错误,可以确定是你的sql server设置有问题,或已存在该login帐号或该数据库 ' call AddUserToMSSQL("testlogin","iamhere","db_test")
Sub AddUserToMSSQL(StrLoginName,StrPwd,StrDBName) '定义服务器变量和系统管理员登录信息,根据具体情况修改

Dim StrServer,StrUid,StrSaPwd StrServer="(local)" StrUid="sa" StrSaPwd="" Dim Conn '数据库连接
Dim StrDSN '数据库连接字符串
Dim StrCmd '命令字符串
StrDSN="driver={SQL server};server="&StrServer&";uid="&StrUid&";pwd="&StrSaPwd&";database=master" '建立和数据库master的连接 set Conn = Server.CreateObject("ADODB.Connection") Conn.Open StrDSN
'新建一数据库 StrCmd="CREATE DATABASE "&StrDBName Conn.execute(StrCmd) '新建一登录帐号 StrCmd="sp_addlogin '"&StrLoginName&"','"&StrPwd&"','"&StrDBName&"'" Conn.execute(StrCmd) Conn.Close
'建立与新建数据库的连接,并赋给新登录帐号访问新建数据库的权利 StrDSN="driver={SQL server}; server="&StrServer&";uid="&StrUid&";
pwd="&StSarPwd&";database="&StrDBName StrCmd="sp_grantdbaccess '"&StrLoginName&"'" Conn.Open StrDSN Conn.execute(StrCmd)
'使新登录帐号成为新建数据库的拥有者 StrCmd="sp_addrolemember 'db_owner','"&StrLoginName&"'" Conn.execute(StrCmd) '关闭释放连接 Conn.Close Set Conn=Nothing Response.Write "用户 "&StrLoginName&" 成功建立!,并且已为他建立了一个数据库 "&StrDBName&"!" End Sub

posted @ 2009-10-20 12:03 军 阅读(204) | 评论 (0)编辑 收藏