Skip to content

Commit 0f47ab9

Browse files
committed
solve 5th problem of 'string' in C
1 parent 804b4fb commit 0f47ab9

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"stdio.h": "c"
4+
}
5+
}

a.out

136 Bytes
Binary file not shown.

solve_problem.c

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,22 @@
7474
// }
7575
// 👉👉 🔹🔹 question 4️⃣ take a string input from the user using %c
7676

77-
#include <stdio.h>
78-
int main(){
79-
char srt[15];
80-
char ch;
81-
int i = 0;
82-
while (ch != '\n')
83-
{
84-
scanf("%c" , &ch);
85-
srt[i] = ch;
86-
i++;
87-
}
88-
srt[i] = '\0';
89-
puts(srt);
77+
// #include <stdio.h>
78+
// int main(){
79+
// char srt[15];
80+
// char ch;
81+
// int i = 0;
82+
// while (ch != '\n')
83+
// {
84+
// scanf("%c" , &ch);
85+
// srt[i] = ch;
86+
// i++;
87+
// }
88+
// srt[i] = '\0';
89+
// puts(srt);
9090

91-
return 0;
92-
}
91+
// return 0;
92+
// }
9393

9494
// #include <stdio.h>
9595
// int main(){
@@ -108,8 +108,29 @@ puts(srt);
108108
// return 0;
109109
// }
110110

111-
// #include <stdio.h>
112-
// int main(){
113-
// return 0;
114-
// }
111+
112+
// |🌟 ✨| salting
113+
114+
// // 👉👉 🔹🔹 question 5️⃣ find the salted from a password entered by the user
115+
// if the salt "123" & added that the end
116+
117+
#include <stdio.h>
118+
#include <string.h>
119+
void salting(char password []);
120+
int main(){
121+
char password[100] ;
122+
scanf("%s" , password);
123+
salting(password) ;
124+
125+
return 0;
126+
}
127+
void salting(char password []){
128+
char salt [] = "123 ";
129+
char newPass[200];
130+
strcpy(newPass , password); // newPass = something
131+
strcat( newPass , salt); // new pass = something + 123 || strcat = +
132+
puts(newPass);
133+
134+
135+
}
115136
// 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟

0 commit comments

Comments
 (0)