200 Posted Topics

Member Avatar for pooja.singh.3950

do { printf("|......|\n"); printf("|..c...|\n"); printf("|..ch..|\n"); printf("|..chm..|\n"); } while (0);

Member Avatar for deceptikon
0
230
Member Avatar for vedel.bajic

Look into [WinSock](http://msdn.microsoft.com/en-us/library/windows/desktop/ms740673(v=vs.85).aspx) when programming on a windows platform and BSD Sockets for Linux. You can also use [Boost.Asio](http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio.html). [Beej's socket guide](http://beej.us/guide/bgnet/) is also a well-written source to learn how sockets work for a beginner.

Member Avatar for Gonbe
0
224
Member Avatar for sarah.mathieson.7

What does the &arr[i] do? I think it has something to do with pointers but I don't understand pointers either so I'm just trying to get the basics... You are (kind of) correct. '&' as a unary operator is used to obtain the memory address of a variable. For example, …

Member Avatar for Gonbe
0
243
Member Avatar for Magic681

You commented your code with some steps. You could say your program does the following: 1. Intialize random seed. 2. Generate secret number. 3. Play guessing game. (keeps starting guess attempts until guessed, tracks amount of tries) 4. Do guess attempt. (either right or wrong, involves asking the user for …

Member Avatar for ravenous
0
388
Member Avatar for nitin1

Hmm bit-wise operators don't seem to be blacklisted. You could implement binary long division with them.

Member Avatar for somjit{}
0
224
Member Avatar for augustinquizzy

Yes, and I like turtles. -edit- In case it isn't clear: What is your question exactly??...

Member Avatar for Ancient Dragon
0
186
Member Avatar for weblover

You'd have to resize your 2-dimensional array as you read the file. Initially you should allocate the array dynamically using malloc(). Then read from the file and when you run into array boundaries expand it using realloc().

Member Avatar for weblover
0
7K
Member Avatar for vicky30312

There's quite a bit wrong in your code. 1. Note that 'int' is for storing integers. You almost seem to want to use it as an enumeration (enum keyword) but you don't initialize the values. When querying for input using '>>' it will try to read an integer because the …

Member Avatar for Gonbe
0
333
Member Avatar for umesh314

You can't say anything useful about the code, only that it results in undefined behaviour; you're writing to the same variable twice or more without an intervening sequence point. See section J2 and section 6.5 [here](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf). -edit- Looked up the exact point in section J2 I wanted to refer to: …

Member Avatar for Lucaci Andrew
0
252
Member Avatar for Mainul20

You can either implement your own classes to deal with it, although if building something serious (that requires performance) you're likely better off using an external library. A couple that come to mind: [TTMath](http://www.ttmath.org/) [GMP](http://gmplib.org/)

Member Avatar for Gonbe
0
71
Member Avatar for rithish

It does it recursively. It goes down the correct path until it reaches the correct position. (at which point *leaf will be NULL) You seem to implement a binary search tree although you cannot insert the same value more than once. I do not know if this is desired but …

Member Avatar for Gonbe
0
114
Member Avatar for rithish

I believe you made a topic about binary trees before and your case was a binary search tree right? (for everynode the condition holds that every node in it's left subtree is smaller than the node's value and every node in the right subtree is bigger or equal) You should …

Member Avatar for Gonbe
0
143
Member Avatar for dooboosjsdjs
Member Avatar for on93

One thing to look out for is integer division. the return type of fact, x and n are all integers. Try this: #include<iostream> using namespace std; int fact (int no) { int total; for (int i=0; i<=no; i++) { if(i ==0) total = 1; else total = total * i; …

Member Avatar for on93
0
138
Member Avatar for SuburbanSamurai

This should work: #include <fstream> #include <iostream> #include <string> using namespace std; struct CALL_DATA { string list; int number; int lcmonth; int lcyear; }; int main() { int i = 0; CALL_DATA listd[100]; ifstream file ("list.txt"); if (file.is_open()) { while (file.good()) { char temp = 0; getline(file, listd[i].list); // The …

Member Avatar for Gonbe
0
223
Member Avatar for Transcendent

How did you declare your function? The function/prototype should be defined as: void computeOrder(int& spoolOrderAmount, int& spoolStockAmount, double shippingHandling = 10.00); and the implementation as: void computeOrder(int& spoolOrderAmount, int& spoolStockAmount, double shippingHandling) { // code }

Member Avatar for Gonbe
0
208
Member Avatar for mangalasadu

The result of "pow(2,31)" is a double. You apply a bitshift operation on it, which is not possible. Replace pow(2,31) with ((unsigned int)pow(2,31)) and it should work. You don't need pow to begin with though, you don't have to start from the most significant digit as you're just counting bits. …

Member Avatar for Learningvinit
0
208
Member Avatar for chandan127

1. You declare "census city[10];" within the loop while it's also declared outside of it.. 2. The issue is similar to your other thread. See my awnser there: http://www.daniweb.com/software-development/c/threads/437105/scanf-is-skipping-in-last-input-.-if-i-use-int-instead-of-charcode-is-runn 3. Use fgets() instead of gets(). Summary of the problem: With the first scanf a newline remains in the stream. gets() …

Member Avatar for Gonbe
0
80
Member Avatar for 0773247886

Do you mean something like this: #include <iostream> using namespace std; int min (const int a, const int b); int max (const int a, const int b); int main() { int a, b, c; cout << "Enter three numbers: " << endl; cin >> a >> b >> c; cout …

Member Avatar for vijayan121
0
173
Member Avatar for Learningvinit

char *p1="Name"; // Non-const pointer pointing to non-const char. const char *p2="Name"; // Non-const pointer pointing to constant char. char const *p3="Name"; // Alternative syntax for p2. char *const p4="Name"; // Const pointer pointing to non-const char. const char *const p5="Name"; // Const pointer pointing to const char. ++p1; // …

Member Avatar for nitin1
0
547
Member Avatar for Nomi55

Hmm vague code is vague. I made a quick adjustment based on what i THINK you're trying to do here: #include <stdio.h> main() { char a[4][4]; int row,col; // Note that the body of this loop is executed only twice. // Is this what you want? for (row=0;row<4;row=row+2) { for …

Member Avatar for Gonbe
0
177
Member Avatar for tanvir.firuz

Try something like this: #include <stdio.h> #include <windows.h> const int DELAY_IN_MICROSECONDS = 100; int main (void) { char symbol = 'a'; while (1) { putchar(symbol++); if (symbol > 'z') { symbol = 'a'; putchar('\n'); } fflush(stdout); Sleep(DELAY_IN_MICROSECONDS); } return 0; } More information about Windows' Sleep function here: [MSDN](http://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx)

Member Avatar for Gonbe
0
131
Member Avatar for arjun.kancharla23

What kind of keyboard hits? Do you want to detect any form of keypress? Does it have to happen while another activity is going on? Be more specific. It's likely (it depends on what you want exactly) that it's not possible in a platform independent way. Assuming you develop on …

Member Avatar for Gonbe
0
539
Member Avatar for acerious

The code in itself is quite poor. In addition it's not clear to me what the program SHOULD do. Can you explain what the input is supposed to represent, when and which scores should be elinated and other relevant information? When entering the values you supplied the application outputs: > …

Member Avatar for Gonbe
0
157
Member Avatar for chulu

A high "cool story bro" factor on this one.. You omit information and you do not provide any attempts done by yourself or even own thoughts on how to fix it. You could follow the primary-school like methods of multiplication e.g. 18 18 -- * 144 // 8*8 = 64. …

Member Avatar for Gonbe
0
102
Member Avatar for ownedbynothing

You use some variables that aren't declared in the code. (e.g. mallocing with the size of "means" but later copying "mea" to that buffer. I will just assume this is correct, as I have no other choice) The essence of your problem is the following line: tmp2->meaning=tmp3; Once you've found …

Member Avatar for Gonbe
0
1K
Member Avatar for nitin1

Hmm how do you brute force it currently? Some optimizations (but it's still brute forcing) would be to: - don't count the amount of digits per attempted number (or maybe not at all) instead start at i=10, j = 1 where you multiply i by 10 everytime your number hits …

Member Avatar for Gonbe
0
127
Member Avatar for prince26121991

1. You shouldn't really use gets(). 2. You're mixing scanf() and gets(). It's possible, but not recommended. Keep in mind that gets() looks for a newline (or eof) while scanf() tries to obtain the minimal and will keep the newline in the stream. (in this case) You could place a …

Member Avatar for prince26121991
0
120
Member Avatar for noahjonesnoah

Definately possible but quite challenging to find an optimal solution. Going to write down a quick first thought.. To make your example a little bit more complex say there's the following lines as well: StateNumber NextStateC 2 1 3 1 Given have the table filled already every branch of paths …

Member Avatar for Gonbe
0
300
Member Avatar for rithish

Infix, prefix and postfix are merely notations. For example 1 + 2 : Infix, The '+' operator is written between the operands it applies to. 1 2 + : Postfix (Reverse Polish Notation), the '+' operator follows it's two operands. + 1 2 : Prefix (Polish Notation), the '+' operator …

Member Avatar for Gonbe
0
174
Member Avatar for ElDuderino12

An easy approach would be to determine the mean in the first pass through the file, then go through the file again to determine the standard deviation by squaring the differences of every number with the mean and then take the square root of the average of those values. There …

Member Avatar for Gonbe
0
1K
Member Avatar for code_r

> So what doesn't work? You need to give us informations if you need help. > how can I do it reading from the file? It's clear what he wants to achieve. Going by his code sample it's also clear what isn't working. But I know you have a reading …

Member Avatar for code_r
0
251
Member Avatar for revelator

"Multiple switch" case, I am not sure what you mean by this. Checking for multiple cases is what you'd typically use a switch for so yes, multiple "case" statements are allowed. Nesting a switch within a switch is also allowed. The switch body is just a normal or compound statement …

Member Avatar for revelator
0
205
Member Avatar for nitin1

There's multiple ways to do this. This could be solved with (discrete) math alone although I think you're aiming for a more brute-force approach right? In that case a logical start would be to implement the AdjBC() function. You don't have to start at the most significant bit for obvious …

Member Avatar for Gonbe
0
176
Member Avatar for straylight

This assignment contains easy to identify subtasks which can be expressed in their own functions. Following this idea I would suggest something like the following: #include <stdio.h> #include <string.h> #include <ctype.h> #include <assert.h> // The maximum length of a string. #define STRING_MAX (40) // Function declarations/prototypes. void reverse_substring (char str[], …

Member Avatar for rithish
0
1K
Member Avatar for Brigadier

Start simpler. Create a function with the following signature: void repeat_character(const char symbol, const int amount) what it should do is it prints 'symbol' to stdout 'amount' times. So, print_character('2', 5); should print 22222 Once you have that solving your original problem should be easier. If you don't know how …

Member Avatar for Adak
0
117
Member Avatar for prakhs

I didn't really go over the code yet but how does it run for you when you change struct node *list1, *list2; to struct node *list1 = NULL, *list2 = NULL; ?

Member Avatar for deceptikon
0
145
Member Avatar for salakgocap

Introducing a flag with additional code to set and check it seems like a poor solution, especially when it's not needed. Doesn't simply moving the printing instruction out of the loop do what you describe? main() { FILE *file = fopen ("COMMAND.txt", "r"); FILE *file1 = fopen ("LOG.log", "a"); if …

Member Avatar for WaltP
1
105
Member Avatar for rithish

While this doesn't even deserve an answer as you don't even ask a proper question (You just dump your code and state "it doesn't work!") you could try this. I'm not going to explain anything about it I guess as you didn't ask me to. It's also a naive implementation …

Member Avatar for Gonbe
0
196
Member Avatar for Gonbe

Hello Daniweb. [B]Scenario[/B] For a project we have to write a irc server. For this, we first wanted to investigate what kind of server architecture we should apply. (e.g. multithreading, multiplexing, multiprocessing etc.) We've written simple servers which implement different architectures. The servers basicially receive a message, and then send …

Member Avatar for nezachem
0
140
Member Avatar for Gonbe

Hello Daniweb, I've ran against an issue in my code and i'm not sure why I receive an error. I've managed to reproduce the error with the following code: [CODE="C"] #ifdef _WIN32 #define PERFORMANCE_METING #endif #ifdef PERFORMANCE_METING #include <windows.h> #endif #include <stdio.h> #include <stdlib.h> typedef enum { FALSE, TRUE } …

Member Avatar for Ancient Dragon
0
152
Member Avatar for Gonbe

Hello Daniweb community, Recently I bought a new harddrive. Below is a link to the manufacturer's website and the model: [url]http://www.seagate.com/ww/v/index.js...D&locale=en-US[/url] I connected the drive according to the instructions and then booted up my computer. The drive got detected in the BIOS so i booted up Windows. I then went …

Member Avatar for Gonbe
0
173
Member Avatar for rajdesire

As far as I know Volatile is used when you don't want the compiler to perform certain optimizations with regards to value changes. (It is as if you say: "The value of this variable may change, even if this doesn't happen in the current program". This may happen in embedded …

Member Avatar for gerard4143
0
144
Member Avatar for mmasny

What you are doing now is trying to use a [URL=http://en.wikipedia.org/wiki/Function_object]functor[/URL]. (overloaded () operator for that object) Use the initialization section of the constructor to initilize the object: [CODE="C"] Desktop::Desktop() : otwarte_okna() { x1=y1=0; x2=y2=1000000; } [/CODE]

Member Avatar for mitrmkar
0
102
Member Avatar for haseeb1431
Member Avatar for vmanes
0
153
Member Avatar for Gonbe

Hello Daniweb, I'm trying to create a very simple shell for practicing purposes, but i'm a little bit puzzeled about the usage of execve, the function i use to execute a file. The code fragment underneath shows my usage: [CODE="C"] childPID = vfork(); if (childPID == 0) { execve(input.process, input.parameters, …

Member Avatar for gerard4143
0
273
Member Avatar for deepin

Alternatively you could set your condition as the loop condition. A cunstruction I would use would be a do-while setup, as displayed below: [CODE="C"] int i; do {//return from the loop only when the input is zero printf("\n1: Stack1\n2: Stack2\n0: to return\n"); scanf("%d",&i); switch(i) { case 1: printf("1"); break; case …

Member Avatar for WaltP
0
3K
Member Avatar for froggy1976

Your code seems to contain a lot of errors. You want to create a class called DayOfTheWeek that represents a day of the week. It looks like you have tried to store the actual data in a string object that you made private. That's an idea that could work. (The …

Member Avatar for C++Rookie
0
191
Member Avatar for asm2hex

I'm not sure if I understand your question correctly, but you could just copy the data like you would with non-allocated data. So something like this is what I mean: [CODE="C"] #include <stdlib.h> #include <stdio.h> #define AMOUNT_OF_DATA 20 int main (int argc, char *argv[]) { int *allocatedData = (int*) malloc(AMOUNT_OF_DATA …

Member Avatar for Narue
0
104
Member Avatar for Gonbe

Hello. I'm writing a program in C that should ask for a line of input, and extract the process name and parameters. This doesn't have to be totally bulletproof at this point. An example input could be: "Hello these are parameters". On this example "Hello" would be the string i …

Member Avatar for Dave Sinkula
0
2K

The End.