Hsn
anyone know to solve strings of mathematical expression into an integra
Im thinking u may want to look into finite state machine .. it might give you idea how to write your own parser
coal
a state machine will allow you to read the input and have a meaningful context of what you're expecting to parse
coal
for example, you could start in a state 0 to read a value and 1 for operators, then based on that context you can classify the characters you're reading to serialize them into something you can work with
Hima
Hsn
?
It wont parse negative number .. first number is negative not an operator
Hima
It wont parse negative number .. first number is negative not an operator
sure correct , put some checks and it will be fine
Anonymous
Hey guys, I saw a really weird form of an IF statement. It's condition part has a block statement. it looks like the following code segment. if (({int a = 0; int b = a + 3; b > 0;})) { // do whatever you want } My question is "How this could work?" , I never saw an IF condition part have a block statement before...😰
Anonymous
Thanks for all your explanations.👏
itsmanjeet
I have a vector<int> of size(1024) Then i take the iterator vector<int>::iterator Iter = vec.begin() Then what i know is Iter == pointer to the first value (currently) *Iter == first value Then what the Iter[0] denotes
Pavel
I have a vector<int> of size(1024) Then i take the iterator vector<int>::iterator Iter = vec.begin() Then what i know is Iter == pointer to the first value (currently) *Iter == first value Then what the Iter[0] denotes
iter[N] points to an element N elements away from iter. For zero it's the same element. For one it's the next element. I think it's done this way to mimic behaviour of raw pointers pointing to array elements.
itsmanjeet
Ok mean vec = [1, 2, 3, 4] iter = vec.begin() + 2 iter[0] = 3 iter[1] = 4 iter[-1] = 2 If i understand the thing correctly ?
itsmanjeet
itsmanjeet
Thanks
Yamu
Hello guys I am a newbie here
Yamu
I have a problems with c programming
Yamu
#include<stdio.h> int main(){ int i; //used to count loop int n; //Size of array int position; //The array location where you want to delete int array[n]; //let user to input the size of array printf("1.Please input the size of array n:"); scanf("%d",&n); //let user input the element of array printf("2.Please input the elements of array:\n"); for(i=0; i<n; i++){ printf("Array[%d]: ",i); scanf("%d",&array[i]); } n = n-1; //Decrease a speac of array after deletion for(i=n-1; i>=position; i--){ array[i-1] = array[i]; } printf("The result after deletion is:"); for(i=0; i>n; i++){ printf("Array[%d] = %d", i, array[i-1]); } return 0; }
Yamu
when i output it, it show nothing
Yamu
-------------------------------- Process exited after 4.59 seconds with return value 3221225725 Press any key to continue . . ..
Yamu
There is no error occur when i compiled it
Yamu
Please help me! : )
Ethan
Your loop logic is off, try rethinking a better solution
Yamu
Thank You guys for your helping!!
Yamu
I will try it as you guys told thank you..
Null
!report
\Device\NUL
That's not how dynamic array works in C, stack allocated array once its created, it can't be resized
\Device\NUL
Please don't PM Teb
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys, happy holidays; I'm writing a program and I have the need to delete one element from an array of integers in C. My question is: do I need to use dynamic memory management? Because that seems pretty fair to me to be honest, but I've seen some tutorials on the internet that don't use realloc() or any other dynamic Memory management function. So I'm a little bit confused
Yamu
let me try it thank you
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys, happy holidays; I'm writing a program and I have the need to delete one element from an array of integers in C. My question is: do I need to use dynamic memory management? Because that seems pretty fair to me to be honest, but I've seen some tutorials on the internet that don't use realloc() or any other dynamic Memory management function. So I'm a little bit confused
Like, if my array is Int *arr= (1,2,3,4,5} And I want to remove 2,3 I have arr= {1,4,5} But now the array is smaller. So it does fit in the previous memory region allocated for it when declaring the array, but I'm wondering if this could lead to problems in much more complex softwares
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Ok so basically I'm just saying that since I'm reducing array size it will surely fit the memory region allocated earlier
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
mahdi13
Hello In the switch, I want to check two values ​​in a case like this case 'a' || 'A': ... break; If the user enters a or A, this case will run, but as I wrote, it don't work how can I do that? writ separate case for each one?
\Device\NUL
Thank you for your help!
Welp, stack memory is limited, use dynamic allocation for big memory usage instead
Hades
decltype vs auto, what's the difference?
Ömer Faruk Aydın
Hello there, i have a question: I've been working on swapping 2 words in a string.(In C language) However using another array is not allowed. Basically code should look something like this: int main() { char str[SIZE]; printf("Enter 2 words: "); sgets(str); printf("[%s]\n", str); // [hello friend] //code printf("[%s]\n", str); // [friend hello] }
Igor🇺🇦
decltype vs auto, what's the difference?
decltype returns the type of expression in it auto deduces the type of the declared variable.
Ömer Faruk Aydın
I'd really appreciate if anyone can give me tips for the algorithm
João
Hi
João
Anyone can help me?
Suka
I'd really appreciate if anyone can give me tips for the algorithm
char test[] = {"one two"}; char *var1 = strchr(test, ' '); int var2 = var1 - (test); printf("%s %.*s\n", test + (var2 + 1), var2, test);
Prince Of Persia
is there anyway to get all input from a istream object as iterators or as string ? (without getting line by line in while loop)
Prince Of Persia
But two or three times slower than getting line by line
Anonymous
how can I read the numbers in keyboard with c
Morsal
Hi all, I have question. What computers that used by giant companies such as Google and Facebook?
Anonymous
how can I read the numbers in keyboard with c
in python we use n=input('give me number') is that possible in c to write in screen message and same time return value?? 🙏
Anonymous
in python we use n=input('give me number') is that possible in c to write in screen message and same time return value?? 🙏
simple answer: no you can write function that doesnthat very easily with getchar and putchar in c and thats what python does in the background (and makes a bunch of other assumptions that makes the language so high-level and (imo) shit)
Anonymous
you can use printf("Enter a number: "); scanf("%d", &a);
Cri | ferrosxlupus
Ludovic 'Archivist'
Hi all, I have question. What computers that used by giant companies such as Google and Facebook?
They use all matters of computer architectures and systems. They strive to use the best (cheapest) tool for the right job
Ludovic 'Archivist'
They have the money that affords these amounts of cost optimization. On the other side of the spectrum, I can only use the best tools available *to me* for the job, which is often X86_64 and AVR or some suboptimal flavour of ARM
Ludovic 'Archivist'
😭
Morsal
They use all matters of computer architectures and systems. They strive to use the best (cheapest) tool for the right job
You're right ... That is it .. But I think they use supercomputers as main computer for management and compiling .. Is ti ?
Ludovic 'Archivist'
You're right ... That is it .. But I think they use supercomputers as main computer for management and compiling .. Is ti ?
No, they use convenience (read cheap custom) servers, they just use thousand of them. They subdivide their services They try to avoid services getting big enough to require a server farm to compile but when they do, they use distcc. Very large companies don't have the affordance to fail. As such they cannot use a big centralized system but use piecemeal bit spread on hundreds of servers so that say a rack or two catching fire is never a problem
L.Ashurmatov
Hi, everyone How to find time implementation of code in c programming language For example cpp have a library ctime to find implementation time but I didn't find in c programming language? For instance In python for that have time library Start = time.time() .. .. End = time.time() In the end End - start if I'm not mistaken
?
@SilhouetteInDark why do you think are function declarations there in C and C++ ? why we need to write a function declaration on top of a function call when the actual function definition is below that function call
Ömer Faruk Aydın
Vishal
Given a string, how many different substrings exist in it that have no repeating characters? Two substrings are considered different if they have a different start or end index. Example S = "abac" The substrings that have no repeating characters in them are "a", "b", "a", "c", "ab", "ba", "ac", and "bac". Note that "aba" and "abac" do not qualify because the character 'a'is repeated in them. Also note that two substrings, "a" and "a", both qualify because their start indices are different: s[0] and s[2]. There are 8 substrings that have no repeating characters. crintion ho ritor