All you need to do is put the function in one file and include it in the main file using "include" keyword. An example is below where we have two files mainfile.c and func.h. func.h will have the...
Type: Posts; User: jas_atwal
All you need to do is put the function in one file and include it in the main file using "include" keyword. An example is below where we have two files mainfile.c and func.h. func.h will have the...
Thank you. But I assume that is not a standart C function. It is included in conio.h in windows. Is there a smiliar implimentation for linux/unix systems as well?
Maybe curses.h. I'll try that.
I want to display a character at specific positions on screen using values like x and y. Is it possible?? i am not able to find the correct function. I tried to google but no luck.
cout << "String is "<< color;
In the above code color is a string. Would it work? what is the correct syntax to output a string to screen?
Hi guys,
I wrote the following code:
#!/bin/sh
echo this is simply to demonstrate the use of error_exit
error_exit i am exiting..
echo this won't be displayed
That surely is an excellent command to start with. But as it invokes a new shell to execute a command, it may be slow to execute.
Instead you should functions from unistd.h
This is a sanity check. An IP packet has a TTL field of 8 bits. that means a count of 256. That means an IP packet can traverse 256 hops before it is dropped? isn't that a too large value for real...
Yes, you are very correct. it is Integer overflow. I tried to use long type instead of int in hope that i may be able to increase this limit from 16 to a little more. But did not work.
Anybody...
I am able to compile it.
I have the below program to calculate factorial. It is working good for values upto 16. But when I give a value greater than 16, like 17 the output is in negative. e.g for 17 i get -288522240. Why is...
I understand that in C we need to define every function that we are going to use before main function calls it. e.g:
#include<stdlib.h>
#include<stdio.h>
int square(int);
main() {
int...
Following version of your program is working fine with gcc( if we ignore a few warnings that it through):
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
int...
Gotya!! THank you!!
<< split from this dead thread - http://cboard.cprogramming.com/showthread.php?t=1115 >>
<< read the rules about thread bumping! >>
So int x has to be global all the time??
Thank you so much for your suggestion. I have made some changes to my code taking your suggestion:
//This is a small program to reverse the string provided by user
#include<stdio.h>...
Actually I did include the above in read code. Just skipped these to save some space :)
Ok, good to know that!
I am writing this just for educational/practise purpse. Thought maybe some...
Hi Guys, Happy New Year to all of you!! I wrote the following code to reverse a string input from user. I'm wondering if there is a better way to go about this. Any suggestions please?
int...
Thank you so much for your replies. Your answers have cleared my confusion. Have a great new year all of you!!
I agree that Array indexes are 0-based. So that means buffer[chars_read - 1] is the last character and it will be overwritten. Please correct me if I understand wrong.
Thank you!
Hello everybody!
I have a query regarding the code below. Here within while loop, there is a line buffer[chars_read-1] = '\0'. Now I understand that this is being done in order to make char array...
When exit() is called, the program terminates. Any statement after exit want be executed at all. If you want to pass values you may use return(). e.g:
int test(){
return(1);
}
int...
I'm using the following code to demonstarte threads and semaphores. it is works well all the way but the program hangs at the point where the threads join. They never join and program hangs there...
Thanks Mat.... now another question...
what would you say about a stupid mistake like the one i made above??!!!
And..... how do you know i am using bubblesort. i haven't mentioned the filename...
and scanf will accept a pointer. so replace scanf("%d", a) with scanf("%d",&a);
I am so sorry for this putting this question so vaguely and in a dumb manner: Let me say this again:
I have the following code:
int main(void) {
FILE *ptr;
char buff[100];
ptr =...