1,494 Posted Topics

Member Avatar for seo2005

try two for loops...one embedded into the other [CODE] for (i = 0; i < num; ++i) { for (j = 0; j < num2; ++j) {} } [/CODE]

Member Avatar for archi vachhani
0
206
Member Avatar for Teelnaw

I think if you look closely, you'll find that your switch statement is outside your loop. This is your for loop [code] for (i = 0; i < 32; ++i) grade[i] = 0; [/code] To include the switch you'll need to add braces like [code] for (i = 0; i …

Member Avatar for ari$av3s
0
280
Member Avatar for anjoz

Extended ascii characters are 8 bits, see link below [url]http://telecom.tbi.net/asc-ibm.html[/url] Try reading your characters into an unsigned char variable.

Member Avatar for abhimanipal
-1
1K
Member Avatar for kirtics344
Member Avatar for maqsood8797
1
167
Member Avatar for denkfix

So what you want is a function that creates a new string which is a copy of the string being past... Why not change the 'const std::string& a_string' parameter to 'std::string& a_string' and change original string or is that outside the requirements? Your question, get the iterators for the string's …

Member Avatar for denkfix
0
223
Member Avatar for zachcoenen4

Try looking at the code below..You should be able to finish it with this hint.. [code] #include <iostream> int main(int argc, char *argv[]) { int count_one = 1; int count_two = 10; for (int i = 0; i < 10; ++i) { for (int j = 0; j < count_one; …

Member Avatar for zeeshan soomro
0
470
Member Avatar for wildplace

Try something like below [code] #include <stdio.h> #include <stdlib.h> unsigned long *lptr = NULL; int main() { lptr = (unsigned long*)malloc(sizeof(unsigned long)); /*check if allocation failed*/ __asm__ ( "movq %0, %%rax\n\t" "movq $6, (%%rax)\n\t" :"=m"(lptr) ); fprintf(stdout, "ans->%lu\n", *lptr); return 0; } [/code]

Member Avatar for wildplace
0
123
Member Avatar for gman1991
Member Avatar for gman1991
0
109
Member Avatar for wildplace

For this to work, you'll have to inspect each character from the stream using the isdigit() function.

Member Avatar for Narue
0
156
Member Avatar for lochnessmonster

I literately typed this in google [quote] c++ number to string [/quote] and it returned itoa(). [url]http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/[/url]

Member Avatar for Caligulaminus
0
105
Member Avatar for narlapavan
Member Avatar for vedro-compota

The operating system will use the next lowest file descriptor for that application. It really makes sense if you think about it. Would you expect the operating system to return a random number? The third value is used if open creates a new file, its the umask value that's applied …

Member Avatar for vedro-compota
0
184
Member Avatar for rockerjhr

Try adding to the top of your make file [code] all: list.o listinterface.o [/code]

Member Avatar for rockerjhr
0
141
Member Avatar for acpr

If the rows of data are consistent, why not create a structure to represent a row and have an array of structures.

Member Avatar for acpr
0
212
Member Avatar for rockerjhr

Your call to atoi may be failing. From my help file [quote] The atoi() function converts the initial portion of the string pointed to by nptr to int. The behavior is the same as strtol(nptr, (char **) NULL, 10); except that atoi() does not detect errors. [/quote] Try using strtol() …

Member Avatar for Ancient Dragon
0
238
Member Avatar for wesduncan

You were close... [code] #include<stdio.h> int main (void) { int row,col; int num; num=10; row=0; col=0; while(row<=num) { row++; while(col<row) { col++; printf("* "); } printf("\n"); col = 0; } return 0; } [/code]

Member Avatar for aamira_s
0
102
Member Avatar for devesh2222
Member Avatar for yashsaxena
0
77
Member Avatar for myk45

You can't create abstract objects, hence the term abstract. You can create a pointer to an abstract type but its must point to a derived object. Here's a simple coded example [code] #include <iostream> class expr_node//abstract { public: virtual ~expr_node() {} virtual std::ostream& print(std::ostream & out) const = 0; }; …

Member Avatar for myk45
0
179
Member Avatar for MasterGberry

The strcmp() function requires c-strings which must be terminated with '\0'. What your passing to strcmp() is a char pointer to one character. c-strings [code] char *str1 = "this is a c string";//compiler adds the '\0' char str2[] = "this is another c string";//again the compiler adds the '\0' char …

Member Avatar for WaltP
0
113
Member Avatar for nory22

Try this link [url]http://www.daniweb.com/software-development/cpp/threads/350132[/url] Didn't realize this was C++, replace std::cout with fputs().

Member Avatar for Narue
0
114
Member Avatar for Buffalo101

[QUOTE=Buffalo101;1525061]Thanks for the reply, Dragon. Unfortunately, I think the problem is somewhere else. I've included the whole code here: [url]http://www.daniweb.com/software-development/cpp/threads/357691/1525051#post1525051[/url][/QUOTE] That code is C++, its not C.

Member Avatar for gerard4143
0
401
Member Avatar for fibbo

It could be this function [code] std::vector<passenger*>& passenger_queue::passengers_at_floor(int floor_) [/code] Try changing it to [code] std::vector<passenger*>& passenger_queue::passengers_at_floor(const int floor_) [/code]

Member Avatar for fibbo
0
7K
Member Avatar for gerard4143

How do you initialize a dynamic structure that has a const data member? I can provide an ugly hack but I'm at a loss as how to do it correctly. Actually, can you do this in a platform independent way? [code] #include <stdio.h> #include <stdlib.h> struct mys { const int …

Member Avatar for Narue
0
164
Member Avatar for asrockw7

Try reading the last section of this page [url]http://pw1.netcom.com/~tjensen/ptr/ch8x.htm[/url]

Member Avatar for asrockw7
0
260
Member Avatar for Labdabeta

Your reading 100 digits, that's one big number. Its even bigger than an int. A safer conversion function would be strtol(), atoi() does not detect errors.

Member Avatar for WaltP
0
134
Member Avatar for JDevelop
Member Avatar for lochnessmonster
Member Avatar for thekashyap
0
109
Member Avatar for mars001

Did you allocated the memory? Try something like below. [code] #include <stdio.h> #include <stdlib.h> #define STR_SIZE 35/*don't use magic number use descriptive labels*/ #define ARR_SIZE 6 int main() { int i = 0; char *p[ARR_SIZE]; for (i = 0; i < ARR_SIZE; ++i) p[i] = (char*)malloc(STR_SIZE);/*allocate memory*/ for(i = 0; …

Member Avatar for mars001
0
227
Member Avatar for moroccanplaya

Here's a simple server which receives a filename from a client, opens the file and writes the data to the client. If the file can't be found, it writes an error message to the client. From this bare shell, you should be able to create your simple web server. [code] …

Member Avatar for abhimanipal
0
175
Member Avatar for subwired

[code] uint16_t _inverse_logic:1; [/code] This creates a variable _inverse_logic which is one bit in size.

Member Avatar for abhimanipal
0
120
Member Avatar for moroccanplaya

I say this in the most constructive way, learn how to program in C and then learn how to program client/server applications and then learn the HTTP protocol. Line 8 is wrong.

Member Avatar for dondajr
0
103
Member Avatar for triumphost

This will compile on both windows and Linux but you'll need the mingw32 compiler for windows and the GCC compiler for Linux.

Member Avatar for triumphost
0
115
Member Avatar for BlueDevil

Its not about answers, its about guidance. Please post the code that you have completed so far.

Member Avatar for abhimanipal
0
97
Member Avatar for maxxjr

This should get ptr pointing at the first element of buffer. [code] unsigned short* ptr = (unsigned short*)buffer; [/code] Please note, when you increment ptr(or access an element with an index ptr[i]), the address increments by sizeof(unsigned short) and not by sizeof(unsigned char).

Member Avatar for gerard4143
0
212
Member Avatar for nunopedrosilva

Enumerated types are constant integrals, they are created by the compiler, so you can't convert a string to an enumerated type. Your enum [code] enum MyType{ Saw, Saw2, Saw3 }; [/code] the compiler would assign these values. Saw = 0, Saw2 = 1, Saw3 = 2

Member Avatar for rubberman
0
6K
Member Avatar for lochnessmonster

Why memory maps? Exe's, Dll's or shared objects need to be mapped into memory before they can be execute, you can't execute code from a drive it must be mapped into memory(RAM). Is it better? Depends, what are you reading and what are you doing with it.

Member Avatar for rubberman
0
163
Member Avatar for itslucky

Well you could find out the hex value of 2584 and then place the appropriate values in the correct array elements or you could extend your array to five elements and create a c-string and use the function atoi() like below. [code] #include <stdio.h> #include <stdlib.h> int main() { char …

Member Avatar for Arbus
0
135
Member Avatar for Derek Elensar

I would look up the functionality of getline(). [url]http://www.cplusplus.com/reference/iostream/istream/getline/[/url]

Member Avatar for Derek Elensar
0
180
Member Avatar for Voidz

Read this [url]http://gcc.gnu.org/onlinedocs/cpp/Pragmas.html[/url] It pretty much explains it in the simplest terms

Member Avatar for gerard4143
0
72
Member Avatar for sdr001
Member Avatar for m1n1m3

Right away, I would use array notation. [code] information = r_ptr[locationNumber].y; [/code] Your 2D array. Is that a pointer to pointer like [code] struct ruudud **r_ptr; [/code] or [code] struct ruudud r_ptr[4][4]; [/code]

Member Avatar for gerard4143
0
230
Member Avatar for newbie_in_c

Try creating your function like so [code] void myfunction(int array1[][4], int array2[][4]) [/code] And calling it like so [code] myfunction(myarray1, myarray2); [/code]

Member Avatar for newbie_in_c
0
139
Member Avatar for Philiplee

If your using bits then maybe you should consider a structure with bits fields. [code] struct my_bits { unsigned int one:1; unsigned int two:1; unsigned int three:1; unsigned int four:1; unsigned int five:1; unsigned int six:1; unsigned int seven:1; unsigned int eight:1; unsigned int nine:1; unsigned int ten:1; }; [/code]

Member Avatar for WaltP
0
95
Member Avatar for rockerjhr
Member Avatar for gerard4143
0
248
Member Avatar for jackmaverick1

When you pass a variable's address via a pointer, your just saying this is where I am. I hold the location of the variable in my value or I hold the value NULL.

Member Avatar for gerard4143
0
135
Member Avatar for RyanMcMillan
Member Avatar for c_newbie1

Your not guaranteed how the arguments in printf are evaluated, left to right, right to left..It depends on the C compiler your using!!!!!!!!!!!!!!!!!!!!!(many ! so the reply is urgent).

Member Avatar for c_newbie1
0
137
Member Avatar for lima01

I'm starting out with Qt4 and so far I'm impressed with the libraries and supporting tools/IDE like Qt Designer, Qt Creator, Kdevelop.

Member Avatar for gerard4143
0
192
Member Avatar for Tamlyn

You have a number of questionable things in that function. [code] float calcActualAmount(float amountP, int nrChildrenP) { float leftToSpend; if (calcAllowedPerChild(nrChildrenP) > 180) amountP = 180; else if (calcAllowedPerChild(nrChildrenP) < 180) leftToSpend = calcAllowedPerChild(nrChildrenP) - 100; do { for (int i = 1; i <= 5; i++) { switch (i) …

Member Avatar for Tamlyn
0
381
Member Avatar for harish9

When you have a pointer defined like so [code] char *ptr = "hello world"; [/code] It creates a read only character pointer. If you require a char array that's writable then use. [code] char ptr[] = "hello world"; [/code]

Member Avatar for rubberman
0
146

The End.