Talula
I tried, but when "A" become "T", the function turn "T" into "A" and "A" into "T". It never end.
Don't check the same location and you're probably not replacing the letter you're adding to the string. There is another way to do it, where you could add to the string if the initial string is empty.
Talula
I tried, but when "A" become "T", the function turn "T" into "A" and "A" into "T". It never end.
Simple example would be #include <iostream> using namespace std; int main() { string X = "TATTA"; for (int i = 0; i<= X.length()-1; i++) { if (X[i] == 'T') X[i] = 'A'; else X[i] = 'T'; } cout<<X; }
Anonymous
Any one teach me how to add a two number 😜😜😜😜
Anonymous
im sorry im not a c or c++ developer but i just wanna ask a question is there anyway to convert .fmx oracle forms file type to .fmb
Shubh
int a,b,c,d,e,f,g; printf("Enter 7 numbers separated by space:\n"); scanf("%d %d %d %d %d %d %d", &a,&b,&c,&d,&e,&f,&g); int x=a + b % (int)((float)c / (float)d) % e * f - g; printf("%d", x);
An electricity board charges the following rates for the use of electricity: For the first 200 units; 80 P per unit For the next 100 units; 90 P per unit Beyond 300 units; Rs. 1 per unit All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the names of users and number of units consumed and printout the charges with names
Shubhi
I have been getting an error in the last line of this program
Shubhi
#include <stdio.h> #include <stdlib.h> struct listNode{ int vertexNo; struct listNode *next; }; struct Graph{ int v; int e; struct listNode *adj; }; struct Graph *adjListOfGraph(){ int i , x, y; struct listNode *temp=(struct listNode*) malloc(sizeof(struct listNode)); struct listNode *t; struct Graph *g = (struct Graph*) malloc(sizeof(struct Graph)); printf("Enter the number of vertices and edges:\n"); scanf("%d%d",&g->v,&g->e); g->adj=(struct listNode*) malloc(sizeof(struct listNode)*g->v); for(i=0;i<g->v;i++){ g -> adj[i].vertexNo = i; g -> adj[i].next = g -> adj+i; } for(i=0;i<g->e;i++){ printf("Enter the pair of vertices connecting the edges:\n"); scanf("%d%d",&x,&y); temp->vertexNo=y; temp->next=g->adj[x]; } }
Shubhi
Its showing .....a value of type "struct listNode" cannot be assigned to an entity of type "struct listNode *"....please if someone could help
Shubhi
C
Shubhi
Adjacent list representation of graph..
Anonymous
Can anyone make an interpreter in c programming language??? Please ping me asap
Amu
Hi, ive been trying to create the linux ls -R functionality that recursively lists directories using c, i have made some progress but i’ve been stuck on some aspects. I’ll paste the code below, i’d appreciate it if anyone can help. thanks
Amu
if (list_all == false && list_long == false){ char recursion_buf[512]; if (dir->d_type == DT_DIR){ if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) continue; printf("%s/%s\n", dirname, dir->d_name); snprintf(recursion_buf, sizeof(recursion_buf), "%s/%s", dirname, dir->d_name); list_dir(recursion_buf, list_long, list_all, recursive); } printf("%s\n", dir->d_name);
Puspam
how to solve
By programming and using your brain
Puspam
An electricity board charges the following rates for the use of electricity: For the first 200 units; 80 P per unit For the next 100 units; 90 P per unit Beyond 300 units; Rs. 1 per unit All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the names of users and number of units consumed and printout the charges with names
Create a loop going through all the users. Create an amount variable for each user. Add ₹100 to the amount. Read how many units are consumed. If units<=200 then add units*0.80 else add 200*0.80 and units=units-200 If units<=100 then add units*0.90 else add 100*0.90 and units=units-100 Add units*1 If amount>400 then add 0.15*amount Print the amount
Anonymous
Hi family
D
Hi
Anonymous
why is this simple loop not working? #include <stdbool.h> #include <stdint.h> #include <stdio.h> int main() { int64_t n = 1; while (true) { printf("%lli\n", n *= 2); } }
Anonymous
#include <stdbool.h> #include <stdint.h> #include <stdio.h> // unix (not windows) !!!! #include <unistd.h> int main() { int64_t n = 1; int limit = 1000; while (true) { printf("%ld\n", n *= 2); sleep(1); limit--; if (limit == 0) break; } }
Anonymous
wouldn't using a for loop be easier?
Anonymous
this code looks like as experimental, not serious
Abhishek
Hey everyone, I am trying to setup wxWidgets using MinGW64 and CMake
Abhishek
So far not even a basic empty window application is loading
Abhishek
I have no compilation errors I have compiled wxWidgets from source as a sub_directory
Abhishek
Can anybody help me out?
Abhishek
Fixed, had to disable shared libraries for wxWidgets set(wxBUILD_SHARED OFF) add_subdirectory(wxWidgets)
Amirali
Hi guys does anyone knows how the Checksum works? (i searched in google and youtube but I got more confused) the only thing I know is something related to ascii value of each char !
Anonymous
where can i learn CMake?
Anonymous
any good resources?
touhou
any good resources?
https://cliutils.gitlab.io/modern-cmake/ Idk if this is good resource , but you can check it out.
Anonymous
This seems good thanks
Captain
Use recursion
Anonymous
I wana data base mangement pdf
Talula
I wana data base mangement pdf
Ask that question in database group, this group is for C/C++
Talula
Hi guys does anyone knows how the Checksum works? (i searched in google and youtube but I got more confused) the only thing I know is something related to ascii value of each char !
The simplest way to do CheckSum is to take 4 bytes and XOR it with a key and then take that result and then XOR with next 4 bytes... keep doing that for whole file you'll get a 32 bit checksum.
Felix
Excuse me guys i wanna ask for a solution, i have a program here that accept user's input, i want that when the user's input is == 0 , that 0 is undetected(dissapeared), how can i do that? Thanks.
Felix
I have a program int num; printf("Input Num "); scanf("%d",&num); if (num==0) { num=(deleted by system/not detectable); }
Felix
i want the 0 to be not detected by the system
Naina
How to check for enter key in c++ ?
Anonymous
If you’re using windows you can use windows.h
Anonymous
And the getasynckey function
Anonymous
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate
Naina
Ok , thank you 👍
Dumb
If you’re using windows you can use windows.h
For a universal one could I use getc function and then check the value?
Anonymous
You can probably use posix api and you would have to write your own function
Dumb
Mh got it
Felix
How would this compile?
that's not the point mate
Felix
im asking how can i make the value 0 undetected by system
Talula
im asking how can i make the value 0 undetected by system
See no programming language would prefer to introduce bugs in their coding, what you want is a bug to be used in a place where it would get an error.
Anonymous
he is asking if you press enter without entering a number the program exits
Anonymous
basically check if scanf is empty
Anonymous
scanf is a bad function anyways
Anonymous
maybe GNU Readline would help ¯\_(ツ)_/¯
Talula
he is asking if you press enter without entering a number the program exits
Oh okay... You can try this... #include <iostream> using namespace std; int main() { string str; while (1) { char a = cin.get(); if (a == '\n') { cout << "Enter key is pressed" << endl; break; } else { str += a; } } cout<<str; return 0; }
Felix
He is using C I think
don't mind i can adapt
Anonymous
thank you so much sir, imma try this later
You should learn about dynamic allocation and pointers
Anonymous
They’re fun
Felix
aight noted
Felix
did array categorized as pointers?
Talula
He is using C I think
#include <stdio.h> #include <string.h> int main(void) { char str[10]; while(1) { char a = getchar(); if (a == '\n') { printf("Enter key is pressed\r\n"); break; } else strncat(str,&a,1); } printf("%s\r\n",str); return 0; }
Talula
If you want it to be empty check for empty.
Anonymous
he want's empty
Anonymous
if scanf is empty exit
Anonymous
carriage return hehe
Talula
he want's empty
#include <iostream> using namespace std; int main() { string str; while (1) { char a = cin.get(); if (a == '\n') { if (str == "") cout << "Enter key is pressed" << endl; break; } else { str += a; } } cout<<str; return 0; }