我正在尝试创建状态的字符串视图,因此当被调用时:
#include <stdio.h>
#include <stdlib.h>
// function prototypes
void encrypt(char [], int);
void decrypt(char [], int);
main()
{
char myString[21] = {'\0'};
int iSelection = 0;
int iRand;
srand(time(NULL));
iRand = (rand() % 4); // random #, 1-4
system("clear");
printf("okay");
while( iSelection != 4) {
printf("\n\n1\tEncrypt Clear Text");
printf("\n2\tDecrypt Cipher Text");
printf("\n3\tGenerate New Key");
printf("\n4\tQuit");
printf("\nSelect a Cryptography Option:");
scanf("%d", &iSelection);
switch (iSelection) {
case 1:
system("clear");
printf("\nEnter clear text: ");
scanf("%s", &iSelection);
encrypt(myString, iRand);
break;
case 2:
system("clear");
printf("\nEnter cipher text: ");
scanf("%s", &iSelection);
encrypt(myString, iRand);
break;
case 3:
system("clear");
iRand = (rand() % 4); // random #, 1-4
printf("\nNew Key Generated\n");
break;
} // end switch
} // end while loop
} // end main
void encrypt(char sMessage[], int random)
{
int x = 0;
// encrypt the message by shifting each characters ASCII value
while (sMessage[x] != "\0") {
sMessage[x] += random;
x++;
} // end while loop
x = 0;
printf("Encrypted message is: ");
// print encrypted messsage
while (sMessage[x] != "\0") {
printf("%c", sMessage[x]);
x++;
} // end while loop
} // end encrypt function
void decrypt(char sMessage[], int random)
{
int x=0;
x=0;
// decrypt the message by shifting each characters ASCII value
while (sMessage[x] != '\0') {
sMessage[x] = sMessage[x] - random;
x++;
} // end loop
x = 0;
printf("\n Decrypted Message is: ");
// print decrypted message
while (sMessage[x] != '\0') {
printf("%c", sMessage[x]);
x++;
} // end while loop
} // end decrypt function
它将打印出如下内容:
fmt.Printf("%s", panel.State)
是否可以在嵌套字段上添加方法,然后访问其父结构,例如:
Hi
⚪️⚪️⚪️⚪️⚪️⚪️⚪️⚪️⚪️⚪️
⚪️⚫️⚪️⚫️⚪️⚪️⚫️⚪️⚪️⚪️
⚪️⚫️⚪️⚫️⚪️⚪️⚪️⚪️⚪️⚪️
⚪️⚫️⚫️⚫️⚪️⚪️⚫️⚪️⚪️⚪️
⚪️⚫️⚪️⚫️⚪️⚪️⚫️⚪️⚪️⚪️
⚪️⚫️⚪️⚫️⚪️⚪️⚫️⚪️⚪️⚪️
⚪️⚪️⚪️⚪️⚪️⚪️⚪️⚪️⚪️⚪️