406 Posted Topics
Re: [QUOTE=abhi_marichi;812472]I need to execute some dos commands like executables(.exe) PLEASE HELP ME OUT OF THIS[/QUOTE] Read more about the "system" command in C language.Your every requisite would get fulfilled. Through system command you can call all commands you can call in a command prompt mode and also execute certain kinds … | |
Re: [QUOTE=slimjimmer;814882]Thanks for you help. I have figured out what I am doing wrong. For future reference though, is it possible to declare an array of strings? Isn't that effectively an array of character arrays?[/QUOTE] You are exactly right . Array of strings is effectively an array of character arrays. As … | |
Re: >Naure How about using this assuming the numbers passed as strings are within the integer range... [code=c] if ( argc >= 3 ) { num1=atoi(argv[1]); num2=atoi(argv[2]); printf ( "%d\n%d\n", num1, num2 ); } [/code] Or if the coder is sure to get only singe digit numbers he/she can just use … | |
Re: [QUOTE=gayatridas;815257]I have a sequence of 5 numbers. I want to write it in reverse order. Could you please help me that what will be the algorithm?[/QUOTE] This is different from the question dealt in this thread so start a new one... | |
Re: For pointer concept you look at the post by Naure I am just throwing some light on similarities between variable increment and pointer increment. (Thought that would help you link these two things and understand better.) 1) variable + 1 = value of variable + 1 pointer + 1 = … | |
Re: Hey its simple you just need to do the same working as you would do on a paper. Take the fraction as a string and break it into tokens with delimiter as "/" . Now you get the numbers as characters. Just convert them into integers and use them in … | |
Re: (Someone's really joking with you when he/she said you to write a compiler in 2 months.In this time you cant even study the basics properly.And moreover you don't know whats LEX and YACC is which can be treated as foundation stones to compiler building.So please stay away from words like … | |
Re: [QUOTE=shaieen;811195][B]i research a code, and it goes like this:[/B] [code=c] #include<stdio.h> #include<conio.h> void main() { int a[12],b[12],c[12],i,j=0,k=0; clrscr(); printf("Enter 12 numbers\n"); for(i=0;i<12;i++) { scanf("%d",&a[i]); } for(i=0;i<12;i++) { if((a[i]%2)==0) { b[j]=a[i]; j++; } else { c[k]=a[i]; k++; } } printf("The even numbers are\n"); for(i=0;i<j;i++) { printf("%d\n",b[i]); } printf("The odd numbers are\n"); … | |
Re: Well thats a pretty nice approach. Mainly you need to know one thing.Its up to the coder to use his code in the fashion he likes.If you are using these functions only in this program then let it be in main.c itself. If you think you can use these programs … | |
Re: The above stated answers by luckychap and salem is what you need to do to make your swing move ie clear and redraw. But instead of clearing the entire screen its better to clear only a part of the screen.You can just go through the concept of VIEWPORT and move … | |
Re: Yes you have really messed up the code at some places :) Well I wont give you the codes but will help you out in pointing your errors and what you need to add to your codes.Here it goes: [code] void readA(int A[]){ int A[inte]; printf("\nenter an integer : "); … | |
Re: [QUOTE=ronizam;807812]print the decimal, octal and hexadecimal values of all character between the start and stop character entered by user, For example, if the user enters and 'a' and 'z', the program should print all the character between 'a' and 'z' and their respective numerical values. make sure that the second … | |
Re: [QUOTE=ronizam;807791]i already start with simple program,look like it easy, but when come to more complicated program, dont know what to do, maybe its a late start for me to do programming, i am 33years old, taking online learning, with work and family...[/QUOTE] Salem's guidance is really splendid. You need to … | |
Re: Well when all the functions have been already given in math.h why do you want to re-write them ? You can just take the input in degrees from the user and convert it into radians and feed into functions. Well if you want to know the basics more and write … | |
Re: [QUOTE=odzky;809747]Create a function w/c accepts as input the double numbers x1,x2,x3 and returns to the program the value of the average (x1+x2+x3)/3 as a variable parameter. #include<stdio.h> #include<conio.h> main() { i really dont know what next...........[/QUOTE] Look programming is like a game.It has its own set of rules. On coding … | |
Re: [QUOTE=bhavya_talluri;801595]hi i just want to know how to write a c program for heap sort. please help me[/QUOTE] Do you know how to sort numbers according to Heap Sort manually on paper ? I hope your answer is yes,if not learn that first without it you cant understand how to … | |
Re: @JONZ Your question doesn't specify your need correctly.Well I could frame two questions out of it. So answering them. 1)How to create stacks and trees? Stacks can be created using many methods. By Arrays, using a variable to act as top indicator. By Linked List, using a node pointer to … | |
Re: All the above listed algorithms are the bests you can find to sort an array of numbers but I would prefer this order for you to start with as you are a starter. 1>Selection sort 2>Bubble sort 3>Quick sort 4>Merge sort 1 Tells you how to start sorting with help … | |
Re: Well in my view allocating array[15][100] would be faulty as that may lead to array overflow and illegal memory access in some cases(Because here you are handling files). And not all files are longer there may be small files which may not use most of the allocated memory or some … | |
Re: Not only a structure...You cannot define anything dynamically. You can just set values to already allocated or defined variables.Even in functions like malloc where you allocate memory dynamically during run time you only allocate memory to predefined or declared variables. Creating a completely new entity is not at all possible. | |
Re: [QUOTE=ithelp;801893]Hi C experts, In my code I have got #pragma extern_prefix (push, ""); Some extern function declarations #pragma extern_prefix (pop, ""); So that compiler does not prepend anything to those extern functions , I get an error error #14: extra text after expected end of preprocessing directive Does anyone know … | |
Re: [QUOTE=DLightman;802374]I like the function better. I'm having a bit of a mind block about though. I know I have to iterate through arr[17]. But how do I stop at the 4th element, switch to a new array and read the next 4 chars?[/QUOTE] Well I respect your zeal to write … | |
Re: malloc not freed and Array overflow errors as indicated by Aia should be checked and the error over flow in line no 64 causes error in every compilation and hence comes in notice. But the same Array overflow error in Line 135 comes over only in certain cases and hence … | |
Re: Hey all the beautiful help given to you above should increase the interest in you to build the program.The help given above is splendid read it again. Well try this: 012345678 0123*5678 012***678 01*****78 0*******8 ********* 0*******8 01*****78 012***678 0123*5678 012345678 If you assume the space to be a linear … | |
Re: [QUOTE=bemo55;801600]I just learned pointers in my computer science class and i am having a hard time understanding what they are used for. Are they absolutely necessary to use them when passing arrays from functions ect. or is it just a more efficient way of doing so?[/QUOTE] Don't look at the … | |
Re: [QUOTE=premsharma;801764]hello nice help from this site, pls help me for program problem : C program to read a list of names ending on a '$'. Each name ends on '.' and contains maximum of 30 characters. our program must convert the format as indicated in the example below and print … | |
Re: [QUOTE=monkey_king;800004]Hey, does anyone know if it possible to have something like [CODE] #DEFINE NUM_DEC 4 printf("This is your value:%.NUM_DECf\n"); [/CODE] thanks in advance[/QUOTE] Its impossible because anything other than data type specifiers and escape characters within double quotes of printf function is treated as string or character constant and is … | |
Re: [QUOTE=claretm;800118]Thanks for the reply. If this gives all the prime numbers less than 1000000,how can i modify this to get the largest difference between two consecutive prime numbers? [/QUOTE] Well you need to know one thing very clearly that your program is not generating prime numbers up to 1000000 as … | |
Re: [code=c] void displayUnion( iUnion ); union integer_union { char c; short s; int i; long l; }; typedef union integer_union iUnion; int main() { iUnion value; //code continues [/code] Hey in your program you are declaring a prototype of function display as shown below: [code=c] void displayUnion( iUnion ); [/code] … | |
Re: [QUOTE=priyankasaini;798907]please write a programme to sort array of integers using quick sort[/QUOTE] I hope you have read this community rules. Everyone here is capable of solving this thread but we are here only to help people who really are struggling to get knowledge and are working themselves.Even we are learning … | |
Re: [QUOTE=ajhais;798248]Given a n*n grid with free spaces and obstacles in the form an n*n integer matrix. We need to find shortest between any two given points (x1,y1) and (x2,y2) through the free spaces. We are not allowed to move in diagonal. Please help me figuring out an algorithm for doing … | |
Re: [QUOTE=abby2589;798564]can you give an example of sorting? in c..tnx![/QUOTE] There are many : Bubble Sort,Merge Sort,Quick Sort. And yes "can you give" is one of the phrases you should use in this community only after you yourself do some work on it.Hope you have done it. | |
Re: The real problem here is recognition of a word. And as we all know word is a linguistic concept and we cannot be fool proof while programming for such concepts. The only way I see is to implement AGNI's method for the start and move assuming the sentence is a … | |
Re: Apart from the heavy memory consumption problem stated by "death_o_clock" which need to be corrected,your program has other major errors. 1> picked[8] can carry flags only up to integer 7 and [code=c] for (i = 0; i < 9; i++) picked[i] = 0; [/code] will itself give error.Therefore picked[9] is … | |
Re: Well I am not able to point out your mistakes exactly but this code does work: [code=c] #include<stdio.h> struct node{ int a; char b; }; typedef struct node * NODE; int main() { NODE n; int *in; char *ch; n=(NODE)malloc(sizeof(struct node*)); in=&(n->a); ch=&(n->b); *in=10; *ch='a'; printf("%d %c",*in,*ch); return 0; } … | |
Re: A small addition to both the codes mentioned above. The rule for being a Prime Number in maths states that a number is prime if it cannot be divided by any number (actually any prime number ) <= the square root of the number given. that is: [code=c] for( i=2 … | |
Re: malloc(<size>) just allocates a memory space for the size specified and returns a void * pointer pointing to the starting of the allocated memory block. It returns a void * pointer (so that it can be type cast to any pointer type) and as you know void * pointer itself … | |
Re: I tried your original C file Racenite.c on Windows OS on TC compiler and it is running fine without errors. And no display problem too. | |
Re: All header files are taken from the include directory. May be the compiler is not responding because your newly created header file may not be in its search path. | |
Re: The real essence of C is in the discovery of C by yourself so try to discover more and read books like "ANSI C" by Kernighan and Ritchie. 1.Try to print the Pascal's Triangle (This requires only looping and a bit of array knowledge.) 2.You need to start imagining and … | |
Re: If you just want to extract the index (part after the decimal pointer) you can use this method also (in case your index part is in integer bounds) If you have scanned it as a floating point number: 1>Convert it into a STRING. 2>Then use standard function strtok() with the … | |
Re: Well here is a code in which you can generate numbers from 1 to 1023 i.e all numbers that can be represented in 10 bits.This is just one of the implementation and there are several other simpler ones too...You wanted access for all the bits so this is one way.You … | |
Re: Hey I feel there are some errors in your posted code: [code=c] int main(int argc, char *argv[])/*command line input*/ { int len; char *t[10]; len=strlen(argv[argc-1]); temp[0]=argv[argc-1] if(strstr(t[0],"c"==NULL)/*to check for a c file input*/ printf("Not a c file"); else printf("C file"); } [/code] In line 6 and 7 it should be … | |
Re: Include your codes within the code syntax.Its really hard to analyze it without it.Have a look at the code tags. | |
![]() | Re: Only the IEEE notation of floating point is able enough to hold the planks constant. As it is a very small number and the first non zero number comes only after nearly 33 digits and so your number gets truncated to first 6 places only. Therefore 0.000000 and as soon … |
Re: This isn't so easy.Even long integer cannot hold the complete length of the input you are assuming so we need to split the number into digit basis and proceed. 1>Take three array's A , B and C of size 100 each and initialize all their values to 0. 2>Take the … | |
Re: In my knowledge there is no such inbuilt way in C language to get the last modified time. The file doesn't hold such information even in Linux platforms.The file table has all such information but accessing it through just C language statements is doubtful. May be you can include a … | |
Re: @ahamed101: In my knowledge your usage of void * pointers are wrong. The sole purpose of introduction of void * pointers in C is to include the concept of polymorphism and the basic limitation of void * pointers says that it cannot be dereferenced. that is: [code=syntax] int *p,x=10; void … | |
Re: I may be wrong but what I feel is the pid_t data type within switch() is causing the error with -1. As negativity of the choice element is not correctly defined in some cases its better if you use an integer variable to hold the ForkPid value. as int pid; … | |
Re: Yes you need to remove the usage of "goto" statement.Below is one of the several ways how you can remove the goto. [code=syntax] repeat: printf("\nEnter current year:"); scanf("%d",&cy); printf("\nEnter current month:"); scanf("%d",&cm); printf("\nEnter current date:"); scanf("%d",&cd); printf("\nEnter birth year:"); scanf("%d",&by); printf("\nEnter birth month:"); scanf("%d",&bm); printf("\nEnter birth date:"); scanf("%d",&bd); if (cy<=0 … |
The End.