新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb点虐 %s vbnet数组定义

vb,net中nplot怎么做图例

vb,net中nplot怎么做图例

公司主营业务:成都网站制作、成都网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出高青免费做网站回馈大家。

C[0] C[1] C[2] C[3] C[4] C[5] C[6] C[7] C[8] C[9]

设数组c的首地址为2000,也就是说c[0]单元地址为2000。则数组名c就代表这个首地址。因此在c前面不能再加地址运算符。如写作scanf("%s",c);则是错误的。 在执行函数printf("%s",c) 时,按数组名c找到首地址,然后逐个输出数组中各个字符直到遇到字符串终止标志'\0'为止。

7.3.6 字符串处理函数

C语言提供了丰富的字符串处理函数, 大致可分为字符串的输入、输出、合并、修改、比较、转换、复制、搜索几类。 使用这些函数可大大减轻编程的负担。用于输入输出的字符串函数,在使用前应包含头文件"stdio.h",使用其它字符串函数则应包含头文件"string.h"。

下面介绍几个最常用的字符串函数。

1. 字符串输出函数 puts

格式: puts (字符数组名)

功能:把字符数组中的字符串输出到显示器。 即在屏幕上显示该字符串。

【例7.12】

#include"stdio.h"

main()

{

char c[]="BASIC\ndBASE";

puts(c);

}

从程序中可以看出puts函数中可以使用转义字符,因此输出结果成为两行。puts函数完全可以由printf函数取代。当需要按一定格式输出时,通常使用printf函数。

2. 字符串输入函数gets

格式: gets (字符数组名)

功能:从标准输入设备键盘上输入一个字符串。

本函数得到一个函数值,即为该字符数组的首地址。

vb点虐 中使用C++中带LPCTSTR参数的DLL的问题

你也太牛逼了!!!你不用MFC,你要用WINDOWS API吧,,,你想不用API连SQL???

吐血,累死你啊!!

好,,给你个C++链接SQL2000的例子!

/* 这是一个程序,只使用C++就可以连接数据库,你编译后要按程序要求配置一下环境也许才可以使用*/

/**************************************************

* 操作系统 Windows XP Professional SP2

* 开发环境 Visual Studio.NET 2003

* 数据库 SQL Server 2000

* 注释 配置环境,可以参考代码中的ConnectionString赋值部分

* 另外对于SQL SERVER的密码和用户名得修改一下程序的用户名和密码

* 这个程序用的是SQL SERVER的默认例子数据库,除了用户名和密码,代码基本不用怎么改

* 你多注意一下你的环境比如ODBC呀,数据库的用户名呀,口令呀,还有

* 操作系统,数据库,程序,三方面的配合吧。

**************************************************/

// BeingConnectionStringCpp

#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \

no_namespace rename("EOF", "EndOfFile")

#include ole2.h

#include stdio.h

#include conio.h

// Function declarations

inline void TESTHR(HRESULT x) ;

void ConnectionStringX();

_bstr_t GetState(int intState);

void PrintProviderError(_ConnectionPtr pConnection);

void PrintComError(_com_error e);

///////////////////////////////////////////////////////////

// //

// Main Function //

// //

///////////////////////////////////////////////////////////

void main()

{

if(FAILED(::CoInitialize(NULL)))

return;

ConnectionStringX();

//Wait here for user to see the output..

printf("\nPress any key to continue...");

getch();

::CoUninitialize();

}

///////////////////////////////////////////////////////////

// //

// ConnectionStringX Function //

// //

///////////////////////////////////////////////////////////

void ConnectionStringX()

{

// Define Connection object pointers.

// Initialize pointers on define.

// These are in the ADODB:: namespace

_ConnectionPtr pConnection1 = NULL;

_ConnectionPtr pConnection2 = NULL;

_ConnectionPtr pConnection3 = NULL;

_ConnectionPtr pConnection4 = NULL;

//Define Other Variables

HRESULT hr = S_OK;

try

{

// Open a connection using OLE DB syntax.

TESTHR(pConnection1.CreateInstance(__uuidof(Connection)));

pConnection1-ConnectionString =

"Provider='sqloledb';Data Source='MySqlServer';"

"Initial Catalog='Pubs';Integrated Security='SSPI';";

pConnection1-ConnectionTimeout = 30;

pConnection1-Open("","","",adConnectUnspecified);

printf("cnn1 state: %s\n",

(LPCTSTR)GetState(pConnection1-State));

// Open a connection using a DSN and ODBC tags.

// It is assumed that you have create DSN 'Pubs' with a user name as

// 'MyUserId' and password as 'MyPassword'.

TESTHR(pConnection2.CreateInstance(__uuidof(Connection)));

pConnection2-ConnectionString = "DSN=Pubs;UID=MyUserId;PWD=MyPassword;";

pConnection2-Open("","","",adConnectUnspecified);

printf("cnn2 state: %s\n",

(LPCTSTR)GetState(pConnection2-State));

// Open a connection using a DSN and OLE DB tags.

TESTHR(pConnection3.CreateInstance(__uuidof(Connection)));

pConnection3-ConnectionString = "Data Source=Pubs;";

pConnection3-Open("","","",adConnectUnspecified);

printf("cnn3 state: %s\n",

(LPCTSTR)GetState(pConnection3-State));

// Open a connection using a DSN and individual

// arguments instead of a connection string.

// It is assumed that you have create DSN 'Pubs' with a user name as

// 'MyUserId' and password as 'MyPassword'.

TESTHR(pConnection4.CreateInstance(__uuidof(Connection)));

pConnection4-Open("Pubs","MyUserId","MyPassword",adConnectUnspecified);

printf("cnn4 state: %s\n",

(LPCTSTR)GetState(pConnection4-State));

}

catch(_com_error e)

{

// Notify user of any errors.

// Pass a connection pointer accessed from the Connection.

PrintProviderError(pConnection1);

if(pConnection2)

PrintProviderError(pConnection2);

if(pConnection3)

PrintProviderError(pConnection3);

if(pConnection4)

PrintProviderError(pConnection4);

PrintComError(e);

}

//Cleanup objects before exit.

if (pConnection1)

if (pConnection1-State == adStateOpen)

pConnection1-Close();

if (pConnection2)

if (pConnection2-State == adStateOpen)

pConnection2-Close();

if (pConnection3)

if (pConnection3-State == adStateOpen)

pConnection3-Close();

if (pConnection4)

if (pConnection4-State == adStateOpen)

pConnection4-Close();

}

///////////////////////////////////////////////////////////

// //

// GetState Function //

// //

///////////////////////////////////////////////////////////

_bstr_t GetState(int intState)

{

_bstr_t strState;

switch(intState)

{

case adStateClosed:

strState = "adStateClosed";

break;

case adStateOpen:

strState = "adStateOpen";

break;

default:

;

}

return strState;

}

///////////////////////////////////////////////////////////

// //

// PrintProviderError Function //

// //

///////////////////////////////////////////////////////////

void PrintProviderError(_ConnectionPtr pConnection)

{

// Print Provider Errors from Connection object.

// pErr is a record object in the Connection's Error collection.

ErrorPtr pErr = NULL;

if( (pConnection-Errors-Count) 0)

{

long nCount = pConnection-Errors-Count;

// Collection ranges from 0 to nCount -1.

for(long i = 0; i nCount; i++)

{

pErr = pConnection-Errors-GetItem(i);

printf("Error number: %x\t%s\n", pErr-Number,

(LPCSTR)pErr-Description);

}

}

}

///////////////////////////////////////////////////////////

// //

// PrintComError Function //

// //

///////////////////////////////////////////////////////////

void PrintComError(_com_error e)

{

_bstr_t bstrSource(e.Source());

_bstr_t bstrDescription(e.Description());

// Print Com errors.

printf("Error\n");

printf("\tCode = %08lx\n", e.Error());

printf("\tCode meaning = %s\n", e.ErrorMessage());

printf("\tSource = %s\n", (LPCSTR) bstrSource);

printf("\tDescription = %s\n", (LPCSTR) bstrDescription);

}

// EndConnectionStringCpp

VB点虐 中的图片问题

void CGridImageDlg::OnSave()

{

try

{

pRecordset.CreateInstance("ADODB.Recordset");

pRecordset-Open("SELECT * FROM 基本信息图片",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);

}

catch(_com_error e)///捕捉异常

{

AfxMessageBox("读取数据库失败!");///显示错误信息

}

//删除所有记录

while (!pRecordset-adoEOF)

{

pRecordset-Delete(adAffectCurrent);///删除当前记录

pRecordset-MoveNext();

}

int m_Rcount = 1;

while (m_Rcount m_GridCtrl.GetRowCount())

{

pRecordset-AddNew();

if(m_GridCtrl.GetItemText(m_Rcount,0)!="")

pRecordset-Fields-GetItem(_variant_t("图片编号"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,0));

if(m_GridCtrl.GetItemText(m_Rcount,1)!="")

pRecordset-Fields-GetItem(_variant_t("桥梁编号"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,1));

//获得文件名

CString m_sname;

m_sname.Format("%s",m_GridCtrl.GetItemText(m_Rcount,2));

//获取扩展名

CString m_sExt;

m_sExt.Format("%s%s",_T("."),m_GridCtrl.GetItemText(m_Rcount,4));

//获得主程序的路径

CString sPath;

GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);

sPath.ReleaseBuffer ();

int nPos;

nPos=sPath.ReverseFind ('\\');

sPath=sPath.Left (nPos);

//获取图片数据

CFile f;

CString FilePathName;

FilePathName.Format("%s%s%s%s",sPath,_T("\\临时图片\\"),m_sname,m_sExt); //文件名和后缀名

CFileException e;

if(f.Open(FilePathName, CFile::modeRead | CFile::typeBinary, e)) //打开了一个文件

{

int nSize = f.GetLength(); //先得到文件长度

BYTE * pBuffer = new BYTE [nSize]; //按文件的大小在堆上申请一块内存

if (f.Read(pBuffer, nSize) 0 ) //把文件读到pBuffer(堆上申请一块内存)

{ // +----------------------------------------------

BYTE *pBuf = pBuffer; ///下面这一大段是把pBuffer里的数据放到库中

VARIANT varBLOB;

SAFEARRAY *psa;

SAFEARRAYBOUND rgsabound[1];

if(pBuf)

{

rgsabound[0].lLbound = 0;

rgsabound[0].cElements = nSize;

psa = SafeArrayCreate(VT_UI1, 1, rgsabound);

for (long i = 0; i (long)nSize; i++)

SafeArrayPutElement (psa, i, pBuf++);

varBLOB.vt = VT_ARRAY | VT_UI1;

varBLOB.parray = psa;

pRecordset-GetFields()-GetItem("图片数据")-AppendChunk(varBLOB);

}

delete [] pBuffer; //删掉堆上申请的那一块内存

pBuf=0; //以防二次乱用

f.Close();

}

}

if(m_GridCtrl.GetItemText(m_Rcount,3)!="")

pRecordset-Fields-GetItem(_variant_t("图片类别名称"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,3));

if(m_GridCtrl.GetItemText(m_Rcount,4)!="")

pRecordset-Fields-GetItem(_variant_t("图片后缀"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,4));

if(m_GridCtrl.GetItemText(m_Rcount,5)!="")

pRecordset-Fields-GetItem(_variant_t("拍摄日期"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,5));

if(m_GridCtrl.GetItemText(m_Rcount,6)!="")

pRecordset-Fields-GetItem(_variant_t("图片描述"))-Value=_bstr_t(m_GridCtrl.GetItemText(m_Rcount,6));

m_Rcount++;

pRecordset-Update();

}

}


新闻名称:vb点虐 %s vbnet数组定义
标题路径:http://www.wjwzjz.com/article/ddjejeh.html
在线咨询
服务热线
服务热线:028-86922220
TOP