我有一个函数,在里面,我有两个数组和两个循环。 第一个是字符数组,第二个是具有NULL值的指针数组。在第一个循环中,我将值设置为null。
void printName(char *pointer, int size)
{
char arrayOfChars[10] = "test";
char *arrayOfPointers[10]
// set values to null
for(int i = 0; i < arrayOfPointers; i++)
{
arrayOfPointers[i] = NULL;
}
int j = 0;
do
{
printf("Value: %d: %p\n",arrayOfChars[j], arrayOfPointers+j);
j++;
}
while(j < 10);
}
所以我想要实现的是这样的:
value: t : 0028FEF
value: e : 0028FEY
value: s : 0028FEX
value: t : 0028FEE
答案 0 :(得分:0)
我会做我认为你想要的事情,而不是我认为你要求的事情:
this.form = new Ext.form.Panel({
margin: '10 100 10 100',
xtype: 'panel',
border: true,
layout: 'hbox',
padding: '2 2 2 2',
items: [{
xtype: 'fieldset',
flex: 1,
layout: 'anchor',
title: 'Send Email',
//collapsible: true,
//collapsed: true,
border: false,
defaults: {
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'txtRecipients',
allowBlank: false,
//fieldLabel: 'Last Name',
emptyText: 'Recipients email address',
padding: '2 2 2 2 '
},
{
xtype: 'textfield',
name: 'txtSubject',
allowBlank: false,
//fieldLabel: 'Last Name',
emptyText: 'Subject',
padding: '2 2 2 2 '
},
{
xtype: 'textareafield',
name: 'txtMessage',
allowBlank: false,
//fieldLabel: 'Last Name',
emptyText: 'Type your message here',
padding: '2 2 2 2 ',
rows: 4
},
{
xtype: 'container',
items: [{
xtype: 'button',
margin: '0 0 0 0',
text: 'Send',
width: 80,
height: 30,
handler: function() {
check_email();
}
}]
}
]
},
{
xtype: 'fieldset',
flex: 1,
layout: 'anchor',
title: 'Send SMS',
//collapsible: true,
//collapsed: true,
border: false,
defaults: {
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'txtRecipients',
allowBlank: false,
//fieldLabel: 'Last Name',
emptyText: 'Contact Numbers seperated by comma(,)',
padding: '2 2 2 2 '
},
{
xtype: 'textareafield',
name: 'txt1Message',
allowBlank: false,
//fieldLabel: 'Last Name',
emptyText: 'Type your message here',
padding: '2 2 2 2 ',
rows: 3
},
{
xtype: 'tbspacer',
height: 45
},
{
xtype: 'container',
items: [{
xtype: 'button',
margin: '0 0 0 0',
text: 'Send',
width: 80,
height: 30,
handler: function() {
check_sms();
}
}]
}
]
}
]
});
function check_email(){
// Here you do a validation of the E-mail fields
}
function check_sms(){
// Here you do a validation of the SMS fields
}
答案 1 :(得分:0)
你的意思是:
for(int i = 0; i < 10; i++)
{
arrayOfPointers[i] = &arrayOfChars[i];
}
接下来是:
int j = 0;
do
{
printf("Value: %d: %p\n",arrayOfChars[j], arrayOfPointers[j]);
j++;
}
while(j < 10);