19,876 Topics

Member Avatar for
Member Avatar for techno_weenie

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> ::= ' ' | …

Member Avatar for IsharaComix
0
133
Member Avatar for rico.tee

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 …

Member Avatar for abhimanipal
0
154
Member Avatar for techno_weenie

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 = …

Member Avatar for jephthah
0
144
Member Avatar for Narue

Consider the following program and input file: [code] #include <algorithm> #include <cstdlib> #include <ctime> #include <functional> #include <fstream> #include <iostream> #include <iterator> #include <string> #include <vector> #include "natural_compare.h" struct natural_less: std::binary_function<std::string, std::string, bool> { bool operator()(const std::string& a, const std::string& b) { return natural_compare(a, b) < 0; } }; std::vector<std::string> …

Member Avatar for dusktreader
7
2K
Member Avatar for newcuser

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 …

Member Avatar for jephthah
0
76
Member Avatar for abhimanipal

[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 …

Member Avatar for IsharaComix
0
115
Member Avatar for yona
Member Avatar for josh06

I am 12, mad about computers and skateboarding, im an emo, i know it doesnt sound right that i like programming. anyway, i have started learning c++, only just! I would like to know first of all if it is possible that you can build your own operating system with …

Member Avatar for josh06
0
118
Member Avatar for 28daniela28

Hi, I'm working on a C++ mini-project ( I'm having an unoriented graph for wich I have an admissible flow and I have to determine the minimal flow for it). Everithing works fine, it compiles and runs well (the code is below) but I'm using files to read input and …

Member Avatar for 28daniela28
0
191
Member Avatar for sahiti
Member Avatar for Dave Sinkula
-5
138
Member Avatar for banders7

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.

Member Avatar for jivemaster
0
642
Member Avatar for arakawid2120
Member Avatar for yila

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, …

Member Avatar for yila
0
163
Member Avatar for aya_brea

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 …

Member Avatar for peter_budo
-3
2K
Member Avatar for abarlowa

I need help with the errors in my code. Here is my pseudocode along with my program code following: [B][U]This is my pseudocode:[/U][/B] Start Declare Variable int length int width int area Print (“Enter length of room in ft.: “), Input length Print (“Enter width of room in ft.: ”), …

Member Avatar for abarlowa
0
1K
Member Avatar for newcuser

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> …

Member Avatar for jonsca
0
203
Member Avatar for chriselda

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.

Member Avatar for Dave Sinkula
0
115
Member Avatar for klactose

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 …

Member Avatar for gerard4143
0
174
Member Avatar for adrawat

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 ) { …

Member Avatar for adrawat
0
399
Member Avatar for newcuser

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 ] = …

Member Avatar for mitrmkar
0
183
Member Avatar for dragontruong

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 …

Member Avatar for dragontruong
0
111
Member Avatar for iarkey

Ok well I'm making a console msn client. [CODE]#pragma comment(lib, "wsock32.lib ") #include <windows.h> #include <iostream> #include <stdio.h> #include <string.h> int main(){ char buf[12]; WSAData wsdata; WORD wsver=MAKEWORD(2, 0); int nret=WSAStartup(wsver, &wsdata); if(nret != 0){ std::cout<<"Startup failed, error code: "<<WSAGetLastError(); WSACleanup(); return -1; } std::cout<<"Init success\n"; SOCKET kSock=socket(AF_INET, SOCK_STREAM, 0); …

Member Avatar for iarkey
0
149
Member Avatar for daveoffy

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.

Member Avatar for daveoffy
0
191
Member Avatar for exonwarrior

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 …

Member Avatar for Salem
0
169
Member Avatar for Iam3R

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 …

Member Avatar for Salem
0
76
Member Avatar for Iam3R

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 …

Member Avatar for yila
-2
102
Member Avatar for katwalatapan

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 …

Member Avatar for katwalatapan
0
185
Member Avatar for lewashby

I'M reading the book that's in the title. Let me show you what's going on. I'M given the following code, an example of Inheritance. [CODE]using System; namespace CritClone { class CritViewer { static void Main(string[] args) { CritViewer cv = new CritViewer(); }// end main public CritViewer() { Clone myClone …

Member Avatar for apegram
0
146
Member Avatar for Eternity[LK]

Hi. I have never used a command-line compiler before and I'm very confused now. I need to use this compiler for my home assignments in one of my subjects in University. I installed the compiler but I don't know how to use it. Help file says: [I]To see a list …

Member Avatar for Eternity[LK]
0
143
Member Avatar for hno

HI I want to write a class that it gets two decimal numbers and add them without using decimal expression like double and float . for example 12/05 + 1/98 =14.3 How can I do so ? thanks

Member Avatar for Ancient Dragon
0
46
Member Avatar for suta6

Question 1: [CODE]main() {int i=-3,j=2,k=0,m; m=++i||++j&&++k; printf("\n%d%d%d%d",i,j,k,m); } [/CODE] ans is -2201 how? Question 2: [CODE]main() { int a,b; a=sumdig(123); b=sumdig(123); printf("\n%d%d",a,b); } sumdig(int s) { static int s=0; int d; if (n!=0) { d=n%10; n=(n-d)/10; s=s+d; sumdig(n); } else return(s); } [/CODE] please explain the ans

Member Avatar for WaltP
-2
90
Member Avatar for COKEDUDE

Can someone please explain the meaning of these return 1 vs return 0 vs break. I know 1 generally means true and 0 generally means false but how would they effect a return statement? Also when would you wanna use a return statement instead of a break statement and vice …

Member Avatar for WaltP
0
257
Member Avatar for jballen87

I'm trying to create a program in C# that allows for arithmetic of Complex Numbers. Just adding, subtracting, multiplying and dividing. Anyone got any suggestions?

Member Avatar for ddanbe
0
857
Member Avatar for klactose

Hello all, When I try to compile a small program I am getting an error that I do not quite understand. I get this error: media_tracker1.c: In function 'add': media_tracker1.c:152: error: expected expression before ';' token when I try to compile this code: [CODE= "c"] #include <stdio.h> #include <stdlib.h> #define …

Member Avatar for klactose
0
101
Member Avatar for jigglymig1

I have to write a program that accepts a pointer to a c-string as its argument. The function should return the charater that appears most frequently in the string along with the number of times it appears. for example, if i input "hello dolly" the output would be: "l sppears …

Member Avatar for r.stiltskin
0
161
Member Avatar for sivaslieko++

hi, I have a problem with BST. For example after the insertions of below numbers, 23 1 45 2 3 5 52 234 31 The output should be like this way: [B]23[/B] [B][/B][B]1,45[/B] [B][/B][B]-,2 | 31,52[/B] [B][/B][B]-,- | -,3 | -,- | -,234[/B] [B][/B][B]-,- | -,- | -,- | -,5 …

Member Avatar for lotrsimp12345
0
114
Member Avatar for ccie007

Hi Friends, I have no clue how to solve following C++ question.I am a learner.Thank you in advance. Question -- Simulation and use of random/io libraries A recent New York Times article featured a report on the usability, stability, and effectiveness (or lack thereof) of current electronic voting systems. By …

Member Avatar for jonsca
0
212
Member Avatar for ccie007

Hi frens, I couldn't compile this solution code given by my university on visual studio.Visual studio works fine with other C++ files. Here are the question and solution code pasted below.I wonder if anybody could try to compile the solution code on thier machine and see if they can run …

Member Avatar for ccie007
0
168
Member Avatar for blerina12

Hello guys. I am working on the code below. I am trying to create my own shell. The code compiles without errors, but when I execute it though it doesn't output anything. I have tried it with /bin/ls as input and it doesn't work. Any suggestions? [code=c]#include <stdio.h> #include <stdlib.h> …

Member Avatar for blerina12
0
1K
Member Avatar for piocasino

Hi frenz, the above code runs perfect. But while printing the arrays x y z the value of y[0]changes...could u plz help me in sorting this problem.. thank u.. this is the output.. [B]x y z[/B] 1 -1 0 2 4 -2 3 3 0 4 2 2 5 1 …

Member Avatar for WaltP
-1
167
Member Avatar for Kevin_160

Hi guys, I have a txt file in which each line contains information in following format: VELOCITY<100.0> LAT_1<N 00 00.0000> LON_1<E 000 00.0000> SIMULATE<false> I would like to write a C or C++ programm to select only the values of the words I need. I need those values to do …

Member Avatar for WaltP
0
94
Member Avatar for daveoffy

I have been trying to check Internet connection but all ways I have tried have failed. Some example code would be great, or the package to use. Thanks very much.

Member Avatar for Narue
0
84
Member Avatar for wilsonz91

Hi, I recently bought a book-The Complete Reference C++ by Herbert Schildt. The first part explains about the similarities about C++ and C. The syntax used is different from the one my lecturer is teaching. eg: cout<< is replaced by printf cin>> is replaced by scanf I would like to …

Member Avatar for wilsonz91
1
201
Member Avatar for burkeyb

Please, I have tried everything that I can learn from a book...any help with this problem is greatly appreciated. I've spent days writing and modifying and I am just lost now. Is there anybody that can help me solve this question using C language? You are developing a database of …

Member Avatar for jonsca
0
314
Member Avatar for johndoe444

Hi, I am required to first read a number, n and then n lines of string. The strings can contain leading spaces which has to be preserved: 2 " hello world" ... using [CODE]scanf("%d", &n); for (int i = 0;i < n;i++) { scanf(" [^\n]", message); .... printf("Case #%d: %d\n",case_count, …

Member Avatar for Salem
0
260
Member Avatar for bbabarajj

How to add 1/1+ 1/2+1/3...+1/9+1/10 . I tried but I am getting answer in negative number.

Member Avatar for bbabarajj
0
2K
Member Avatar for lamoracke

i need a c programme that reads a txt that you chosse then count the number of each word in the programme i have e.g. "hello this word is very funny this is not" hello 1 this 2 word 1 is 2 very 1 funny 1 not 1 i would …

Member Avatar for holocron
0
94
Member Avatar for cthreash

I have a question regarding scope for a character array defined as follows: saveDataObj->save("This is the first entry", 1, 2); Here is how the SaveData class has been defined: [code=c++] class SaveData { struct entry{ const char* data; int data1; } entry* mpData; static int iter; } //Constructor SaveData::SaveData() { …

Member Avatar for cthreash
0
391
Member Avatar for johndoe444

Why the output is 100? [CODE]#define f(g,g2) g##g2 int main() { int var12=100; printf("%d",f(var,12)); return(0); }[/CODE]

Member Avatar for Narue
0
139
Member Avatar for DotNetUser

I'm curious why all the events code and autogenerated code when controls are added to the form are written to the form1.h instead of the form1.cpp. Is this a configuration item? This defeats the purpose of information hiding by separating the declaration from the implementation.

Member Avatar for nehamalpani
0
74

The End.