19,876 Topics
![]() | |
Okay, I am still trying to get used to C++ since I mostly write in Java. I am also new with the two constructor thing mentioned in detail below. Here, I am investigating on writing a class with two constructor. That is, I have heard that you are allowed to … | |
I've tried searching for articles that relate to this issue, but all I keep finding are articles about people who don't know how to define constructors/can't call the parent constructor/etc and I think this will cut straight to the chase. The problem code is as follows: [CODE] #include <stdio.h> class … | |
[CODE]#include<stdio.h> #include<string.h> #define SIZE 100 int main(void) { int array[SIZE], i, n, j, sum=0; printf("Enter some integers:"); for (n=0;n<100;++n) { scanf("%d", &array[n]); if(array[n] == -1) { j=n; break; } j=100; } for(j<=100;i>j;++i){ printf("%d", array[n]); } for(j=0;j<n;++j){ sum=sum+array[n]; printf("The sum is %d\n", sum); } return (0); }[/CODE] [I]Im trying to output … | |
Hello....i am trying to send a file from server to the client using socket programming in C, how do i do this?? basically the client is trying to download a file from the server.... | |
Does someone know how to integrate a collection of programs as one whole program? Thanks. :) | |
Here is a complete and working code that 1. Adds the numbers(input) to get a sum(output) 2. Sorts the numbers in a descending order Can you post any suggestions on how I can improve my code :) main.c [CODE]#include <stdio.h> #include "header.h" main (){ int sum, x, y, z,choices; input(&x, … | |
I'm having troubles with the following code [CODE]#include <stdio.h> #include <ctype.h> int main (void) { int i=0,j=0,row; char str1[5], str2[5]; char machine[4][5]={0}; FILE *fp; fp = fopen("text.txt","r"); while (fscanf(fp,"%s %s",&str1,&str2) == 2 ) { row = str1[1]; while (str2[i] != NULL) { machine[row][i]=str2[i]; i++; } } for (i=0;i<5;i++) for (j=0;j<5;j++) … | |
i need to insert a character on a string . for example input is : cafe the output should be caxzfe . i insert xz . i just know how to concatenate two strings but when inserting a character in a string im totally lost . | |
Hi. I have trouble with getting the following program to convert string to float type. What i need to do is this: 12.345e3 = 12345 12e-2=0.12 -12.34=-12.34 -12.34e3=-12340 -12.34e-2=-0.1234 e: = x 10^ I got it to do the basics. However, It doesn't work in case of negative numbers or … | |
I'm trying to solve this exercise. Write a program that print out the following, user will input the top number: ***** **** *** ** * i made a program similary to this , but user inputs the bottom number ,the output is like this: * ** *** **** ***** here … | |
Please help me fix my code.. It works in CodeBlocks but when I try in Linux, it says it has an error - SEGMENTATION FAULT (core dumped) :( This program converts between bases of a number. After it converts a number it should go back to start to get input … | |
Hi, in the below given program the answer is 1. agpur 2. jabalpur 3. jabalpur I understood the processing for the first two printf statements but for the last printf statement I could not understand the processing. Could anyone please explain. Thanks in advance :) [code=c]#include<stdio.h> #include<conio.h> void main() { … | |
Here is a program I found [URL="http://www.cs.bgu.ac.il/~omri/Humor/ObfsC.html"]here[/URL] [code] #include <stdio.h> main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_, main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13? main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t, "@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\ ;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \ q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \ ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \ iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \ ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \ }'+}##(!!/") :t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1) :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);} [/code] Since I … | |
Can please someone give and explain the algorithm and logic of checking if a given tree is a complete binary tree. Fields available for a node are left and right child and info. Thanks. | |
Hello I've been wondering how to get past the whole "program crashes when user inputs the wrong data type". After extensive amount of google searches I found out that you could use !() as an argument in a loop(or if statement) to avoid that. However by doing that I encountered … | |
The program should change a sentence to pig Latin. [B]Rules[B][/B][/B] A word starting with a vowel should start with a capital letter and the rest with small letters and end with "way". If a word starts with a consonant the first letter will move to the last until it starts … | |
a program that inputs a set of letter codes f for female m for male and gpa then computes and outputs the gpa for both female and male | |
Hi, I have really lame problem which is probably that easy, that I can't get it working. I have program like this below. And I need to make prototype to get it working. But I don't know how it need to look like. I don't want to have these functions … | |
Hello to all. I have a problem with replacing a part of a string with another string. The following code does not work. However, if you remove void in front of replace_str, in Code Blocks i am able to run it (WHY???) despite the fact that i still get a … | |
[URL="http://graphingvariousfunctions.wordpress.com/2011/11/18/how-to-solve-linear-equations-in-10th-grade/"]Solving linear equations[/URL]? It says I have to solve -3k + 4 = 8k - 15 - 6k - 11 On the problem, do I combine like terms on one side first? Like the 8k and the 6k? If so do I add them or subtract them? Can someone please … | |
Hi, I have a problem with c files. I have broken my code to 2 files main.c and unp.h unp.h [CODE] typedef void (*Ptr_To_Function)(void); struct Menu_Record { unsigned int option_number; const char * text; Ptr_To_Function process_function; }; struct Menu_Record* select(struct Menu_Record*,int); struct Menu_Record startup[] = { {1, "Choice1", NULL}, {2, … | |
Hi, I am a student doing my Final Term Project. I am suppose to create a GUI using C# that can control and interact with a Robot call Robonova-1. The robot will be connected to the PC via Bluetooth. I was thinking to have a connection button in my GUI … | |
Ummm hi, Ive been having some problems with a program ive been working on. I want to insert a new value in a column in a table from a calculation i get and replace the original value. Heres the part of the code: private void button11_Click(object sender, EventArgs e) { … | |
I'm really confused as to how to set up this program. The program is to have a function "trap", so I'm guessing that means I have to include a function that solves the integral before my main function? [CODE] #include <stdio.h> #include <math.h> double f(double x) { return exp(-x*x); } … | |
[quote]Yes you can. But going from a useful, good coding practice that makes further development easy to hardcoded, poor coding practice that makes further development hard does not sound like a good idea. Any reason why you would recommend such a move?[/quote] It's because sometimes you do exactly what the … | |
Hi, I am trying to make an image viewer, this is my first time developing a software and I was just wondering how to add properties in my application. I'm creating this software with the help of Gtk and C and now I'm stuck because I want to display the … | |
Hallo! I got the following Decimal IP: "3232235876" it represents "192.168.1.100" I got it in the following way: Code: [CODE] //GET IP if (gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR) { printf("%s","host not found"); } struct hostent *phe = gethostbyname(hostname); memcpy(&addr, phe->h_addr_list[0], sizeof(struct in_addr)); //Convert IP to Decimal notation sprintf(decResult,"%u", addr); sprintf(decResult,"%u", htonl(atoi(decResult)));[/CODE] … | |
I just recently started learning C++, in the book i am learning from there is a problem that asks you to write a simple pasword program. It just asks the user the password and then displays a message wether its right or wrong after they enter it. I am having … | |
Hi all I'm wondering if some one could help me with something as i think i've just forgotten everything i knew :) I have this code: [CODE] #include <stdio.h> #include <stdlib.h> int main() { char A[4]; char B[2]; char C[2]; printf("Enter Numbers: "); scanf("%s",&A); fflush(stdin); printf("Enter Numbers: "); scanf("%s",&B); fflush(stdin); … | |
does somone knows how to creatye a program that well accept five members and display the lowest number | |
Hey, everyone~ Being the second time posting here, I'll try to make it simple but clearly as possible :) So, my assignment this time is about writing a C program to print the following star patterns: [CODE] * * * * * * * * * *[/CODE] So, here is … | |
hello , i want to cin n numbers then to sort the positive numbers in one array, the negative numbers in another array , then to print positive array. So let me explain , i run the program , i enter the 9 , then enter 1 2 3 4 … | |
can an1 plz :)help me to write a program to reverse the individual words present in a string ?? exampe:- my name is raju ym eman si ujar | |
Hi everyone! This is my first post and i'm also a newbie so don't be harsh on me! I have this exercise to do which asks pretty much what the title says. I have a function that reads strings from a file and puts them in an array. Then I … | |
i have made a program with this algorithm but its not working properly my code is given below can you help me to remove the errors [CODE] #include<stdio.h> #include<conio.h> void main() { FILE *f; char ch; int nalpha=0,nword=0,nno=0,nsc=0; f=fopen("abc.txt","r"); if(f!='NULL') { while(ch=getch(f)!=EOF) { printf("%c",ch); if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')) nalpha++; else if((ch==' ')||(ch=='.')) nword++; … | |
Hey I'm currently writing a program which takes a file of data sorts it (using bubble sort) and for some reason I keep getting a segmentation fault. [CODE] #include <stdio.h> #include <stdlib.h> void compare(int numberstocheck[], int n) { int i, j, k; int thebucket[n]; for(i = 0; i < n; … | |
[CODE]#include<stdio.h> int main() { int a,b,c; (printf("\nEnter 2 no.s"))?(scanf("%d%d",&a,&b))?(c=(a>b)?a:b):0:0; while(c>=1) {if(a%c==0 && b%c==0) {printf("\nGCD:%d",c);return 0;} c--; } }[/CODE] | |
Hi everyone, i'm working on a simple console application for my company, which would backup the company's X:\ drive by uploading its data every day at 3:00pm. Questions: 1. Suggestions on how to upload a directory? (if not possible, then is it possible to automatically upload file by file) 2. … | |
i have written a code on assembler... when we enter the mnemonics it will give opcode... when i use %x in the printf it is giving correct opcode.. but when i use %c or %s it is printing some different characters.. but what i want is if i use %s … | |
[B][/B]char c "GATE2011"; char *p =c; printf "%s", p+p 3 p 1 ; = [B][/B] the output is 2011 can any one explain how? | |
hi guy's i need some help. my project is an ATM simulator, to handle screen design i used panel for withdrawal, pin verification, balance etc. to explain further i have 1 panel for withdrawal a panel for pin verification etc. now idont know how to control those panel like if … | |
Hey Similar doubt. Hers is the code snippet.. [CODE]typedef struct { char v; struct node *next; }node; void make_it(node a, char ch); int main() { int i,n=10; char ch[2]; node *a=(node *)malloc(n*sizeof(node)); a[i].v=i+65; a[i].next=NULL; scanf("%s",ch); make_it(a[i],ch[0]); return 0; } void make_it(node a, char c) { node *ptr,*p; ptr=(node *)malloc(sizeof(node)); ptr->v=c; … | |
Could you please help me on this. i tried but i am getting segmantation fault. void qsort(char *v[], int left, int right){ int i, last; void swap(char *v[],int i,int j); if(left>=right) return ; swap(v,left,(left+right)/2); last = left; for(i=left+1;i<=right;i++) if(strcmp(v,v)<0) swap(v,++last,i); swap(v,left,last); qsort(v,left,last-1); qsort(v,last+1,right); } void swap(char *v[],int i,int j){ '... … | |
i studied c++ before c guess that was my mistake... i try to read from a file a set of strings and put them in the new allocated array, i do not understand what is the main thing this code isnt working. i get segmentation fault... and even trying to … | |
Hello, im trying to make a program that opens up jpeg files one at a time and look at there brightness and then if its past a threashold moves the file to a "keep" folder if not moves it to a "varify" folder im new to C# so im not … | |
Heya i ran into a little problem, well more of a mental dilemma using strtok(), i already know how this function works, heres an example code: [CODE] void split_me(char *input) { char *split = NULL; //reset split size_t len = strlen(input); char to_array[len]; int i = 0; split = strtok(input, … | |
[CODE] #include<stdio.h> #include<conio.h> void main() { int a; a=10, // in this line instead of ; i used , printf(" The value of a is =%d", a); getch(); } [/CODE] In the above program instead of using ; i used , but the compiler is not showing any error and … | |
***I have a feeling that there might be something wrong with my function int fgetAnswers(int*pos, char res[], FILE*inp); I am able to compile, but the problem is that wherever the black screen appears, a box would pop out saying that the program has stopped working. Can any of you guys … | |
Is there anything wrong with my coding? Why do I keep getting the message..."Error Opening Input File!" #include <stdio.h> #include <conio.h> void fgetAnswers(FILE*,int*,char[]); void fgetAnswers2(FILE*,int*,int,char[]); int main() {char ans[50],choices[50]; int n,i,id,missed[50],tot; FILE *input,*output; input = fopen("examdat.txt","r"); if(input == NULL) { printf("Error opening input file!\n"); getch(); return 0; } fgetAnswers(input,&n,ans); output … |
The End.