- Strength to Increase Rep
- +7
- Strength to Decrease Rep
- -1
- Upvotes Received
- 20
- Posts with Upvotes
- 18
- Upvoting Members
- 14
- Downvotes Received
- 4
- Posts with Downvotes
- 4
- Downvoting Members
- 3
Re: [QUOTE]We have to use other testing for primality, and I believe cse.avinash has explored using the Sieve of Eratosthenes, which I take it were also unsuccessful. [/QUOTE]You guys should take a look at [URL="http://www.scriptol.com/programming/sieve.php#c"]this[/URL].The second one is much more powerful than the first one(I'm totally amazed by the results). | |
Re: So , what's wrong with your program ? since we're not a psychic or in the mood of playing the"Guess what's wrong with my code" game, you have to tell us what exactly are you looking for. | |
Similar to echoserver, but this one handles multiple clients by forking the process. | |
This is a simple echo server that I've written while learning sockets programming. Compile the server and run it. You can connect to it using telnet like this: telnet localhost 1337 Disconnect the client by typing "/quit" without quotes. | |
This is a simple hangman game that I wrote using my beginner python skills. Though this game is playable, there must be lots of things I must've been doing wrong or the methods I'm using here may be not so pythonic. So I want some suggestions on how to improve … | |
Re: [QUOTE=MrNo;1704619][CODE]#include <stdio.h> #include <string.h> int main() { int count = 0; char *doc; FILE *inp; printf("Enter the file name: "); scanf("%s", doc); inp=fopen(doc, "r"); while((doc = fgetc(doc)) != EOF) { if (doc == ' ') count++; } fclose(doc); printf("%s contains %d words\n",doc,count); return 0; } [/CODE] So basically I'm a … | |
Re: And here's how you use strtok (you know... for future references). [CODE]#include <stdio.h> #include <string.h> int main(void){ char line[20] = "Process0 12 1"; // suppose this is the first line read by fgets char* delim=" "; char* result = NULL; result=strtok(line,delim); if(result != NULL) printf("process:%s\n",result);//store process in an array result=strtok(NULL,delim);//first … | |
If there's a list like below [CODE]s=['b','a','r','r','i','s','t','e','r'][/CODE] and if I tried to remove every 'r' from the list like this [CODE]>>> for x in s: if(x=='r'): s.remove(x)[/CODE] it gives the following result. [CODE]>>> s ['b', 'a', 'i', 's', 't', 'e', 'r'][/CODE] Why isn't the last 'r' removed from the list. | |
Re: [QUOTE]The program runs and compiles. When I enter the two words, it gives me a bunch of random stuff when printing[/QUOTE]That's because scanf is not used like this [CODE]scanf(x1,x2,MAXFORTHIS,stdin);[/CODE] [URL="http://en.wikipedia.org/wiki/Scanf"]click here[/URL] | |
Re: [QUOTE]anyone can tell me what this line does?[/QUOTE]clearly, it's returning the uppercase of the character given to the function.The first return statement only works if the condition cl>='a'(i.e.97 in decimal) AND cl<='z'(i.e 122 in decimal).If it does so then the second return statement is not executed, but if it does … | |
Re: [QUOTE]The case choices does not run after the input of the integers 0 or 1.[/QUOTE] You're missing '&'before 'choice' in your 'scanf' statement . [CODE]scanf("%d",&choice);[/CODE] and another(important!) thing,look at this [CODE]int number, integer,choice; int ArrayN[20]; for(i=0;i<20;i++) { printf("Enter 20 Integers\n"); scanf("%d", &number); printf("ArrayN[%d]=%d\n",i,number);//well, that's stupid! }[/CODE] You have to assign … | |
Re: When you compile your 'C' code, an object file is generated by the compiler. Such object files from each program(from the collection of programs) are build into a single binary(executabe) file by another program called linker. | |
Re: [QUOTE]Can you tell me why use size_t and not int for orig_len and rep_len?[/QUOTE] Using size_t instead of just plain int or unsigned int makes your code more portable since the size of int types vary across platforms. Also the above standard functions expect their third argument to be of … | |
Re: First of all, use code tags whenever you post any code.See that CODE thingy, click that and paste your well formatted code in between. There's no use of this `#include<conio.h> `in your code and why this `char studentanswer[30][30+1];` why not just declare it like this char studentanswer[30][31]; Since you're opening … | |
Re: [ICODE]'fflush(stdout)'[/ICODE] forces the data (if any)in the I/O buffer to be written to the screen .Including a '\n' character(if suitable) in the [ICODE]'printf'[/ICODE] itself also does the same thing.[CODE]printf("incorrect value\n");[/CODE]Remember that [ICODE]fflush[/ICODE] is only used with output streams.Calling [ICODE]fflush[/ICODE] with [ICODE]NULL [/ICODE]argument flushes all the opened streams. | |
Re: [QUOTE]This is a piece of code from some book.[/QUOTE]Is that [URL="http://www.daniweb.com/software-development/c/threads/389911/1679633#post1679633"]the same book[/URL] Narue told you to burn ? [CODE]int fun (const union employee *e); union employee { char name[15]; int age; float salary; };[/CODE]You should declare the union first and then the function 'fun'. [CODE]union employee{ char name[15]; int … | |
Re: The answer is in your error message [CODE]cc1: warnings being treated as errors test_cal.c: In function ‘calsum’: test_cal.c:20: error: control reaches end of non-void function[/CODE]Since function calsum is non-void(means returns something), so you should add a return statement. [CODE]return d;[/CODE] | |
Re: It's a very , very messy code.Here are few things that I saw, that could be potentially causing the problem. 1.You have named many things "Information".First the struct for book data[CODE]/*Structure for book information */ typedef struct Information { char subject [MAXIMUM_TITLE]; char author [MAXIMUM_AUTHOR]; int edition; int year; float … | |
| Re: [QUOTE]The code compiles[/QUOTE]That totally amazes me.[QUOTE] but when I run the program it stops responding once it enters the while loop [/QUOTE]So there's a strong possibility that the problem lies on your while loop statement. [QUOTE][CODE] while (fgetc(inFile) != EOF) != NULL) {[/CODE][/QUOTE]'fgetc' returns EOF when read error occurs or … |
| Re: [QUOTE][CODE]fflush(stdin); //clear the buffer???![/CODE][/QUOTE]Don't use [ICODE]'fflush'[/ICODE] with [ICODE]'stdin'[/ICODE],[URL="http://c-faq.com/stdio/stdinflush.html"]see why.[/URL]also [URL="http://c-faq.com/stdio/gets_flush2.html"]this[/URL]might be helpful. Either use [ICODE]getchar[/ICODE] after each call to [ICODE]scanf[/ICODE] to discard the '\n' from the input buffer or don't use scanf at all.There are [URL="http://docs.google.com/viewer?a=v&q=cache:V6IRXWslR5YJ:www.physics.ohio-state.edu/~ntg/780/handouts/interactive_input_in_C.pdf+how+to+take+inputs+interactively+in+c&hl=ne&gl=np&pid=bl&srcid=ADGEESiscFG8cYzt_lUxZk-m03JcLcXc46ILQ_roQLB6-39GuhhH1EHr_vn4eHVz6wZRzSOgJq3JkHiRbmJmOAM1OUT0mfpyZTeqn3qzq8dXgdXM5eUut8f1ddM-7LDs068yDWDu9lqq&sig=AHIEtbS9Sh6F_jZcWpfTiobG8o9XFEdAGg"]other solutions[/URL] for interactive inputs. |
Re: Well, I compiled your code and entered the number 119 and it printed out: " not a prime Prime number" Do you need help or just mocking us? Can you explain the algorithm you're using for this?(only if you're willing to, there's no pressure) | |
Re: What the ..? I mean, How the ...?[QUOTE]can anyone please tell me whats actually happening in this code. Seems to be as if incremented pointer is pointing to the next bit of same int.[/QUOTE] Why don't you try it in your compiler.did you?[QUOTE]Answer is 2,0[/QUOTE]So you did try it and … | |
Re: [QUOTE]Now, if anyone would be willing to assist me I would greatly appreciate it! [/QUOTE]I don't know what you need help with, since you have it all figured out.If you want us to write(or translate) your code for you, the forum rules wouldn't allow it. You have to use software … | |
Re: you forgot to use '&' in your scanf statement. [CODE]scanf("%d",&n);[/CODE] but what's the point of this [CODE]for(m=1;m<n;m++) for(t=1;t<=m;t++) { n=m*t; printf("%d,%d",m,n); }[/CODE] | |
Re: [QUOTE]no. it is not the expression is wrong. but the program enter the input itself. blank input. and it direct tell to input the correct answer before i get to input anything.[/QUOTE]This is a very common problem.I hope [URL="http://c-faq.com/stdio/scanfc.html"]this[/URL] will make things clear. If not, try to Google it yourself. | |
Re: just use [CODE]char* bus char* dest .../*and later*/ bus="single-decker" dest="taiping"[/CODE] | |
Re: [QUOTE][CODE]for(c_5=1; c_5<=10;c_5++) { for(c_6=c_5;c_6>=1;c_6--) printf(" "); for(c_6=10;c_6>=c_5;c_6--) printf("*"); printf("\n"); } printf("\n"); getch();[/CODE][/QUOTE] initialize c_5 to 0 instead of 1. [CODE]for(c_5=0; c_5<=10;c_5++)[/CODE] | |
Re: [QUOTE][CODE]int main( int argc, char **argv[] ) {//Wrong[/CODE][/QUOTE] [CODE]int main( int argc, char *argv[] ) {//right[/CODE] | |
Re: [QUOTE].for some reason sorting resets all entries to blank.Why is it doing that? I compare two entries, swap if necessary. Trying to figure out where that's failing.[/QUOTE]I compiled and ran your program, It works fine. In my opinion, in your 'DeleteEntry' function, try matching only the user's phone number, because … | |
Re: If you're using the variable val just to do this:[QUOTE][CODE]mov [val], ax add si,val[/CODE][/QUOTE]then there's no need to do so,just do it directly [CODE]add si,ax[/CODE] It's quite difficult to understand what you're trying to do, the information provided here is too little(not enough) and as far as your sample code … |