-
Notifications
You must be signed in to change notification settings - Fork 230
C #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nitidesai21
wants to merge
1
commit into
microsoft:main
Choose a base branch
from
nitidesai21:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
C #57
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #include <stdio.h> | ||
| #include<string.h> | ||
| #define max_student 100 | ||
| #define max_length 50 | ||
| struct student{ | ||
| int id; | ||
| char name[50]; | ||
| char subject[50]; | ||
| float marks; | ||
| char department[50]; | ||
| }; | ||
| student students[MAX_Students]; | ||
| int student_count=0; | ||
| void addstudent(){ | ||
| if(student_count>=MAX_Students){ | ||
| printf("Cannot add more students.It is full"); | ||
| return ; | ||
| } | ||
| Student newStudent; | ||
| newStudent.id=student_count+1; | ||
| printf("enter student id:"); | ||
| scanf("%d",&newStudent.id); | ||
| printf("enter student name:"); | ||
| scanf("%s",newStudent.name); | ||
| printf("enter subject:"); | ||
| scanf("%s",newStudent.subject); | ||
| printf("enter student marks:"); | ||
| scanf("%d",&newStudent.marks); | ||
| printf("enter student department:"); | ||
| scanf("%s",newStudent.department); | ||
| students[student_count]=newStudent; | ||
| student_count++; | ||
| printf("Student added successfully"); | ||
| void displaystudents(){ | ||
| if(student_count==0){ | ||
| printf("No student found\n"); | ||
| return ; | ||
| } | ||
| printf("\nStudent records:\n"); | ||
| printf("Id\tName\tSubject\tMarks\tDepartment\t"); | ||
| for(int i=0;i<student_count;i++){ | ||
| printf("%d\t%s\t%s\t%d\t%s\t",students[i].id,students[i].name,students[i].subject,students[i].marks,students[i].department); | ||
| return; | ||
| } | ||
| } | ||
| void searchstudent(){ | ||
| int id; | ||
| printf("enter student id:"); | ||
| scanf("%d",&id); | ||
| for(int i=0;i<student_count;i++){ | ||
| if(students[i].id==id){ | ||
| printf("\nstudent found\n"); | ||
| printf("%d\t%s\t%s\t%d\t%s\t",students[i].id,students[i].name,students[i].subject,students[i].marks,students[i].department); | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| void updatestudent(){ | ||
| int id; | ||
| printf("enter student id:"); | ||
| scanf("%d",&students[i].id); | ||
| for(int i=0;i<student_count;i++){ | ||
| if(students[i].id==id){ | ||
| printf("enter new name:"); | ||
| scanf("%s",students[i].name); | ||
| printf("enter new subject:"); | ||
| scanf("%s",students[i].subject); | ||
| printf("enter new marks:"); | ||
| scanf("%d",&students[i].marks); | ||
| printf("enter new department:"); | ||
| scanf("%s",students[i].department); | ||
| return ; | ||
| } | ||
| } | ||
| } | ||
| int main(){ | ||
| int choice; | ||
| while(1){ | ||
| printf("\n student record system\n"); | ||
| printf("ADD STUDENT \n"); | ||
| printf("SEARCH STUDENT]n"); | ||
| printf("UPDATE STUDENT\n"); | ||
| printf("EXIT\n"); | ||
| printf("enter your choice:"); | ||
| scanf("%d",&choice); | ||
| switch(choice){ | ||
| case 1: | ||
| addstudent(); | ||
| break; | ||
| case 2: | ||
| displaystudents(); | ||
| break; | ||
| case 3: | ||
| searchstudent(); | ||
| break; | ||
| case 4: | ||
| updatestudent(); | ||
| break; | ||
| case 6: | ||
| printf("exiting program\n"); | ||
| return 0; | ||
| default: | ||
| printf("invalid choice"); | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"use client";
import { useEffect } from "react";
import { getProvider } from "@binance/w3w-ethereum-provider";
import { utf8ToHex } from "@binance/w3w-utils";
import Head from "next/head";
import { useState } from "react";
let provider = getProvider({ chainId: 56 });
const disconnect = async () => {
await provider.disconnect();
};
export default function Home() {
const [account, setAccount] = useState("");
const [chainId, setChainId] = useState("0");
const [cCHangId, setCCHangId] = useState("0xe708");
const enable = async (chainId = 56) => {
provider = getProvider({ chainId });
provider?.setLng("zh-CN");
const accounts = await provider.enable();
console.log("🚀 ~ enable accounts:", accounts);
setAccount(accounts[0]);
};
const getAccount = async () => {
const accounts = await provider.request({
method: "eth_accounts",
});
console.log(
"🚀 ~~ file: ethereum-provider.tsx:32 ~~ getAccount ~~ provider.accounts:",
accounts
);
setAccount(accounts[0]);
};
const signMessage = async () => {
const message = "hello world";
try {
const res = await provider.request({
method: "personal_sign",
params: [utf8ToHex(message), account],
});
console.log("🚀 ~ signMessage ~ res:", res);
} catch (error) {
throw error;
}
};
const getChainId = async () => {
const chainId = provider.chainId;
setChainId(chainId);
};
const changeChainId = () => {
provider?.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: cCHangId }],
});
};
useEffect(() => {
if (!provider) return;
}, [provider]);
const sendTransaction = async () => {
const payload = {
from: account,
to: account,
value: "0x1",
};
const res = await provider.request({
method: "eth_sendTransaction",
params: [payload],
});
console.log("🚀 ~~ file: client.tsx:62 ~~ sendTransaction ~~ res:", res);
alert("success");
};
const opSendTransaction = async () => {
const res = await provider.request({
method: "eth_sendTransaction",
params: [
{
data: "0x14d9e096000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000aadf86a2cc193be699980e7c063ca90bbb487f35",
from: account,
gas: "0x19023",
to: "0x39454a5ad76c379ec1a5281cd93e301fed3995a4", //出错的opbnb合约地址
// to: bridgeAddr[+chainId],
value: "0xffcffbee1f800",
},
],
});
console.log("🚀 ~~ opSendTransaction ~~ res:", res);
};
return (
<>
<title>Create Next App</title>
<main
style={{
height: "100vh",
}}
>
ethereum-provider
<button onClick={() => enable()}>enable
<button onClick={() => enable(787)}>enable Acala EVM
disconnect
getAccount
signMessage
getChainId
changeChainId
opSendTransaction
sendTransaction
<input
value={cCHangId}
onChange={(e) => setCCHangId(e.target.value)}
/>
</>
);
}