15,552 Topics
| |
When you have a function and need to scan for 2 different numbers, should the scanf be in the function or in the main() and why? | |
Could someone explain where and when you would use << and >>. I read these 2 articles but don't really understand them. [url]http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B[/url] [url]http://en.wikipedia.org/wiki/Arithmetic_shift[/url] | |
With my code below how would I either ignore or remove decimal numbers? I tried typecasting it but that messed up my code. I can't think of any way to make a loop to accept only integers either :(. I don't understand why the scanf is accepting decimal numbers when … | |
Hi all, I have to make a function which take as parameter two arrays and merge in one new. For example int array1[][] = {{1 , 2, 3, 4}, {2, 3, 4, 5}}; int array2[][] = {{5 , 6, 7, 8}, {6, 7, 8, 9}}; To take as result arraynew[][] … | |
Can someone tell me why my compiler won't compile this code and how to fix it? [CODE]void gcd(int x, int y) { if (x > y) { int c; while(1) { c = x % y; return y; x = y; y = c; } if (y > x) { … | |
I'm new here so please bare with me if this is the wrong forum (sorry if it is). I put it here because I believe you can contruct a kernel in c right? I've downloaded the linux kernel and thats full of c source files. Anyway, i've been using windows … | |
Hey, my friend and I made this website: [url]http://www.letslearncpp.forumstech.com/[/url]. This website is complete with text and video tutorials made by my friend and I. Please visit this website and join it if you want to. Thank you. | |
[b]Split from - [url]http://www.daniweb.com/forums/thread118867.html[/url] [/b] [code] int main() { int i , parent_id , ans ; parent_id = getpid() ; for ( i = 1 ; i <= 5 ; i++ ) { if ( getpid() == parent_id ) { ans = fork() ; wait() ; } if ( ans … | |
I need to parse a file line by line and check if the line is in a valid BNF format and print it out if it is. Below is my BNF grammar: <line> ::= <program names><spaces><uids><spaces><dest IPs><spaces><ports> <spaces> ::= <blank character> | <blank character><spaces> <blank character> ::= ' ' | … | |
Good day. I need help on a program that I'm working on. It's supposed to take the strings in input.txt and put the odd numbered lines to odd.txt and the even ones to even.txt. here's the code I have made so far... [CODE] #include<stdio.h> #include<stdlib.h> #define p printf #define s … | |
Hello, I'm trying to split a string into 4 separate strings using a delimiter "\n" The initial string is: "/usr/bin/ssh \n * \n 147.188.195.15, 147.188.193.15, 147.188.193.16 \n 22" I would like it to be split up into four different char's so that char *programnames = "/usr/bin/ssh \n" char *uids = … | |
Here is the output for the following code. Can someone help me put the five prods on rows and sales reps on columns w a few changes??? Enter seller's code (-1 to exit): 2 Enter product code: 2 Enter sold for seller 2, product 2: 2 Enter sellers code (-1 … | |
[code=c] int main(int argc, char* argv[]) { int a=3,b=2,c; a=a==b==0; printf("%d\n",a); return 1; } [/code] I cannot understand why this code gives 1 as the answer. According to me , this should be the order of evaluation b==0, which gives false & the expression becomes a=a==0 this should again give … | |
| |
A program that handles either piped input (command/prog | your_prog) or file redirected (your_prog < file_name) input. Determine whether such input exists before issuing a stdin read so that the program does not go into a "waiting for input" state. Written in/for the XP environment. | |
two static arrays size 10 need to be copied to an empty target array size 20. like this: you copy from the first array the nums till arr1[i] = 0 then you switch to the second array and copy to the nums till arr2[i] = 0. then you switch back, … | |
Iam a freshmen and we're given a task to program a calendar using turbo C and does'nt exceed line 54 and some texts are with specific colors.(red) for the days under sunday,(light gray)for the month.... I will really appreciate your help thanks....... Here's the format: ex: enter month:1 january 2004 … | |
I have gotten my program to the point that it allows me to enter the data I want to enter. However, I do not know how to get the program to loop back correctly and ask for salesperson number and stop the loop when I enter -1. Help![CODE] #include <stdio.h> … | |
deleting string... example: deleting... enter string: the quick brown fox and the lazy dog. enter string to delete: the([I]the first one[/I]) new string: quick brown fox and the lazy dog. | |
Hello all, I have a program that creates an array of structs. It is consistently exhibiting 1 of 2 problems and I can't figure out exactly what is wrong, but the problems seem related to each other. Problem 1: For some reason the category member of the mediaItem struct fails … | |
Hi, Im trying 2 write the contents of a input file to an output file in reverse order using file I/O in C. Is there a more efficient way 2 do it? [CODE] int main() { FILE *fp1,*fp2; char ch,arr[100]; int i=0; if( (fp1 = fopen("input.txt","r")) == NULL ) { … | |
Hello, I am attempting to rewrite a program in c. Here is what I have so far. Thanks in advance for assistance. [CODE]#include <stdio.h> void sales[ salesPerson ][ product ] += value; int main() { const int PEOPLE = 5, PRODUCTS = 6; double sales[ PEOPLE ][ PRODUCTS ] = … | |
I am unable to print out the error message when there is no input. I've tried different methods for it, but I can't get it to work. What am I missing? print should be: p2 invalid input but I get: p2 segmentation fault when I do this with an int … | |
I have been trying to get the day of the year into an int(0-365). I have tried the time.h library and did int tm_yday but it returned an incorrect number. I am using Linux. G++(gcc) compiler. Thanks for the help. | |
| Hey all, I'm writing a program in C++ for a contest. The code executes no problem on my computer at school that I'm writing it on. I get all the correct answers. When I upload it however, it keeps on saying "runtime error (SIGSEGV)" Please Help!! here's the link to … |
Hi, i understand the ieee 754 representation. but can some one explain why we need to add specifically 127 to the power of 2. for ex: 5.75 ; 101.110 can be written as 1.01110 * 2 ^ 2 127 +2 = 129 . i.e 10000001 now IEEE 754 of 5.75 … | |
below is one simplest code to illustare the pyramid of number. [CODE] void piramid(int const c) { int r, x; for (r = c; r > 0; r--) { for (x = 1; x < = (2 * c - r); x++) { if (x < r) printf(" "); else … | |
Hello, I have a query on dynamic allocation of memory in C. I am storing 4 seconds of audio data in a buffer allocated with sufficient memory using malloc function. If I wanted to record another 4 seconds of audio in the same buffer, I would have to increase the … |
The End.