The code below
Struct start
{
Int long long n1;
Int long long n2;
Uuid_t dar.
Char sk.
};
Start stobj;
Start initial ()
{//print (p1 q1 N1; Generate the random primes by sever; And the send N to the tag
Uuid_t dar.//the generate the dar
Uuid_generate (dar);
for(i=0; i<16. I++)
{
Printf (" % 02 x - ", dar [I]);
}
printf("\n");
Unsigned char digest [SHA_DIGEST_LENGTH];
SHA1 (dar, strlen (TID) (const char *), digest);
Char SK [SHA_DIGEST_LENGTH * 2 + 1);
For (int I=0; I & lt; SHA_DIGEST_LENGTH; I++)
Sprintf (& amp; SK [I * 2], "x % 02," (unsigned int) digest [I]);
Printf (" SHA1 digest: % s \ n ", SK);
Srand ((unsigned) time (NULL));
While (1) {
P1=MIN + (rand () % (MAX - MIN));
If (judgeprime (p1)) {
cout <"P1=" & lt;
}
The else
continue;
}
While (1) {
Q1=MIN + (rand () % (MAX - MIN));
If (judgeprime (q1)) {
cout <"Q1=" & lt;
}
The else
continue;
}
N1=p1 * q1;
cout <"N1=" & lt;
The p2=MIN + (rand () % (MAX - MIN));
If (judgeprime (p2)) {
cout <"P2=" & lt;
}
The else
continue;
}
While (1) {
Q2=MIN + (rand () % (MAX - MIN));
If (judgeprime (q2)) {
cout <"Q2=" & lt;
}
The else
continue;
}
N2=p2 * q2;
cout <"N2=" & lt;
Stobj. N2=n2;
Memcpy (stobj dar dar, strlen (dar) + 1);
Stobj. Sk=sk;
Return the start;
}
CodePudding user response:
Code as the last I want to return all members of a structure startCodePudding user response:
Start a structure nameAs you can define the start stobj;
You can give stobj assignment, also can return stobj, because he is a variable, and the start is a structure type you can't return to start
Such as int a;
Can you give a assignment can return a but you can't return int o simple example
Int func1 () {
return a;//OK
Return an int;//NG
}
CodePudding user response:
struct start
{
Int long long n1;
Int long long n2;
Uuid_t dar.
Char sk.
};
Struct start initial () {//print (p1 q1 N1; Generate the random primes by sever; And the send N to the tag
Struct start stobj;
Uuid_t dar.//the generate the dar
Uuid_generate (dar);
for(i=0; i<16. I++) {
Printf (" % 02 x - ", dar [I]);
}
printf("\n");
Unsigned char digest [SHA_DIGEST_LENGTH];
SHA1 (dar, strlen (TID) (const char *), digest);
Char SK [SHA_DIGEST_LENGTH * 2 + 1);
For (int I=0; I & lt; SHA_DIGEST_LENGTH; I++)
Sprintf (& amp; SK [I * 2], "x % 02," (unsigned int) digest [I]);
Printf (" SHA1 digest: % s \ n ", SK);
Srand ((unsigned) time (NULL));
While (1) {
P1=MIN + (rand () % (MAX - MIN));
If (judgeprime (p1)) {
cout <"P1=" & lt;break;
} the else
continue;
}
While (1) {
Q1=MIN + (rand () % (MAX - MIN));
If (judgeprime (q1)) {
cout <"Q1=" & lt;break;
} the else
continue;
}
N1=p1 * q1;
cout <"N1=" & lt;While (1) {
The p2=MIN + (rand () % (MAX - MIN));
If (judgeprime (p2)) {
cout <"P2=" & lt;break;
} the else
continue;
}
While (1) {
Q2=MIN + (rand () % (MAX - MIN));
If (judgeprime (q2)) {
cout <"Q2=" & lt;break;
} the else
continue;
}
N2=p2 * q2;
cout <"N2=" & lt;Stobj. N1=n1;
Stobj. N2=n2;
Memcpy (stobj dar dar, strlen (dar) + 1);
Stobj. Sk=sk;
Return stobj;
}
CodePudding user response:
Returns the object of start structure definition