Daulet
Now it finds the length, and I would like it to also find the word itself. I really not understand how to do it
const char* maxword(TQueue& q){ int v; int maxi=0; const char* str; while(!isEmpty(q)){ v=strlen(deQueue(q)); if(v>maxi){ maxi=v; str = deQueue(q); } } return str; }
the best for everyone
// // Created by hassa on 01/10/2022. // #include <stdio.h> #include <stdlib.h> #include <conio.h> #define size 5 int stack[size]; int top=-1; int data; void push(); void pop(); void peek(); void display(); void push(){ printf("Enter the data that you want "); scanf("%d",&data); if(top==size-1) printf("the stack has been overflow"); else{ top++; stack[top]=size; // pay attention // until be full // it needs to understand much better } } void pop(){ int item; if(top==-1) printf("underflow"); else{ item= stack[top]; // pay attention // and if you dont want to write the pop item there is no need to write this line top--; printf("%d",item); } } void peek(){ // top if(top == -1) printf("the stack is empty"); else printf("the top is %d",stack[top]); } void display(){ for (int i=top ; i>=0 ; i--) { printf("the value of the stack << is %d",stack[i]); } } int main() { int choice=1; int d; do { printf("1- to push it\n"); printf("2- to pup them\n"); printf("3- to show the last top\n"); printf("4- to display them \n"); printf(" pressed 0 to get out \n"); printf("Enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: push(); // printf("\nEnter A value:"); // scanf("%d",&d); break; case 2: pop(); break; case 3: peek(); break; case 4: display(); break; default: printf("wrong choice\n"); } } while (choice !=0);// it will get out if we pressed 0 getch(); }
https://dpaste.org/DkXi5#L5,8,10,11
the best for everyone
How it should work?
could you copy and past the code to see it
the best for everyone
I have sent it too in the link
Ольга
https://onlinegdb.com/Co_7gjr21 go through this updated code
Oh now I understand, Thank you, you are already helping me again, thank you for that
Maxter
how to resolve that "cannot find gcc" problem of vs code
Captain
https://dpaste.org/DkXi5#L5,8,10,11
Remove conio.h and getch() and in push function stack[top]=data.
Anonymous
Do you know any online compilers that support modules? I tried to enable/use them on wandbox using gcc and clang but without luck: https://wandbox.org/permlink/dRxtXqPMcMPip8gW
import std.core is supported only by MSVC. Gcc and Clang support header units and building your own modules. Conversion of standard library into modules is still a far way away as far GCC and Clang are concerned. So you will have to live with #include <iostream> in global module fragment or import <iostream> within the module purview (depending on your use cases). This is what GCC and Clang support now
Anonymous
the program throws std::regex_error what() invalid special open parenthesis
There is a problem with regex standard library's support for lookbehind but in most cases you can overcome it. We can help you if you share your code
Void
#include <stdio.h> #include <string.h> #include <math.h> int main() { char a[50]; scanf("%s",a); int i,len,sum,n; len=strlen(a); for(i=0,sum=0;i<len;i++) { sum=sum+(a[i]-48); } int t=sum; //求出位数n for( ;t>0;n++) { t=t/10; } int x; for(x=0;sum>0;n--) { x=sum/int(pow(10,n-1)); switch(x) { case'1':printf("yi");break; case'2':printf("er");break; case'3':printf("san");break; case'4':printf("si");break; case'5':printf("wu");break; case'6':printf("liu");break; case'7':printf("qi");break; case'8':printf("ba");break; case'9':printf("jiu");break; case'0':printf("ling");break; } printf("\n"); sum=sum%int(pow(10,(n-1))); } return 0; }
Void
Guys why does switch statement not work🥲
Руслан
But in case use ' ' words
Void
what's %S.
character string?
Anonymous
character string?
it's %c.
Void
it's %c.
%c is a single character
Anonymous
Void
a character string
the best for everyone
Remove conio.h and getch() and in push function stack[top]=data.
what is the problem with conio.h and getch function
the best for everyone
I did as you told me but the problem still existed
Olayinka
and %s is?
%d=integer , %c = single character, %s = multiple string of character
Deepak Chaurasia
Char a = "hello world" p..("%s", a)?
Deepak Chaurasia
Works or need to declare array
Deepak Chaurasia
asterisk use with char for?
Unknown man
Can anyone tell how to master all topic of c master from question and theory
Sleeves
can anyone help explain whats happening at line 16 here https://hastebin.com/isuhotizug.swift
Sleeves
*pn = 10 * *pn + c - '0';
Daulet
*pn = 10 * *pn + c - '0';
c - '0' is translates ascii character digit to integer.
Sleeves
c - '0' is translates ascii character digit to integer.
im having trouble understanding firstly the purpose of that line of code in the function
Daulet
im having trouble understanding firstly the purpose of that line of code in the function
Constructing number from digits. Example 345. 300 + 40 + 5 Iteration 1. *pn = 3. Read digit and *pn = 3 * 10 + 4 = 34 Iteration 2. *pn = 34. Read digit and *pn = 34*10 + 5 = 345
Daulet
C
Dima
Bruh
Jose
*pn = 10 * *pn + c - '0';
Use parenthesis to help to understanding the pointers use. In my case, I use this conversion to understand the pointer usage: *pn = (10) * (*pn) + (c - '0'); pn[0] = (10) * (pn[0]) + (c - '0'); The point here is separate the usage of the pointer from the declaration of the pointer variable. The function contains various parts: - c - '0' is a hack to convert from ASCII number to their numerical form. The hex code of ASCII characters says that the hex value of 0x30 belongs to the character '0', the 0x31 is the character '1', and so on. This is a hack because it implies you are using ASCII notation to receive the "numbers" The second part, the multiplication, comes before the adding, so 10 * (pn[0]) says you are moving a digit to the left and adding a 0. Visually, it means: 10 * (the value of the first pn) = the partial result (10) * (pn[0]) = partial_result (10) * ( 5) = 50 (10) * (17362) = 173620 This is the mathematical translation of "displace to the left in decimal notation" The last part is the joining of both: The value you received from c (the character) and the value you displaced to the left
the best for everyone
Captain
I did that but nothing has changed
It is working for me, what ide, compiler are u using?
Александр
Hello folks! Could you help me with an advice on how to fix my problem? I have a simple code with raylib. It is a dapper dasher. Character is running, but I want to change it's sprite when it is jumping. However, I cant figure out where to put this logic. It seems like a simple: if (velocity > 0); CharFrame = 4; Does not work.. Could you please help me with that? Dont want to paste whole code in here. Maybe pm? Have a nice evening!
Void
Guys I wonder how to insert spaces in an array of strings?
Anonymous
Tried to use import <iostream>; as in the first example here, with no luck also: https://en.cppreference.com/w/cpp/language/modules
This should work on a local system. But for this you should generate a header unit. As of now online compilers don't support generating header units. You can try it locally. For ex: //Main.cpp import <iostream>; int main(){ std::cout << "Hello World\n"; } On clang, I would compile it like this: >>clang -std=c++20 -xc++-system-header --precompile iostream -o iostream.pcm >>clang -std=c++20 main.cpp -fmodule-file=iostream.pcm -o main >>./main Hello World >>
Anonymous
Anyone can help me In learning c++ from basics
𝓐𝓷𝓴𝓾𝓼𝓱𝓱
Naufal
hello everyone, nice to meet you, here I am as a beginner and want to learn programming, and am looking for a complete c programming cheat sheet, if you have one, I beg you to ask, thank you
Arjun
typedef struct { int data; NODEPTR link; }*NODEPTR;
Arjun
which error
²
need more code
Anonymous
Any recommended book/resource for learning data structures and algorithms for total beginners?
Void
int a[10]; scanf("%d %d %d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&a[10]); Guys why i input 1 0 2 0 3 4 1 9 8 7 and it shows a={1, 1, 0, 2, 0, 3, 4, 1, 9, 8}
Руслан
Using a loop for (int i = 0; i < 10; i++) { scanf("%d", &a[i]); } instead of this scanf("%d %d %d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&a[10]);
Void
&a[0]
Ohhh thanks
Unknown man
calculus discrete math etc, before learnong C
What does that mean sorry i am beginner
/
Help i have a question
/
Why should I pass parameters to a function using the reference
/
I mean the &
/
Like void function( Example& name )
/
It isn't like a pointer if i understanded well
Daulet
It isn't like a pointer if i understanded well
it like pointer but you can't change address of pointer, only value that stored at that address
Daulet
So it is a pointer that cannot be changed
yes and that pointer can't be null
Daulet
/
yes and that pointer can't be null
Yes and do you know what is a static function
/
yes and that pointer can't be null
When it is outside of a class
/
I mean i know what is a static function but i remember i have seen using the static keyword also in functions that aren't in any class