2,384 Posted Topics

Member Avatar for Sukhbir

[QUOTE=Sukhbir]Can someone explain me how these character or escape sequence are treated while finding string size(through sizeof() operator) \0 \n \a \1 \2 for example char str[]="\1abc\0\0" pls explain me in detailed[/QUOTE][code]#include <stdio.h> #include <string.h> void foo(const char *s, size_t size) { size_t i; printf("size = %d\n", (int)size); printf("strlen(s) = …

Member Avatar for Dave Sinkula
0
144
Member Avatar for big buc's fan

[QUOTE=big buc's fan][code] // (30 lines) if (charge>10) // flat rate of 10 dollars is charged charge=10; return charge; } [color=Red][b] {[/b] // What is this doing here?[/color] double hours[CARS]; // store hours parked by the different cars[/code][/QUOTE]I believe your compiler is asking the same question. If the whole code …

Member Avatar for frrossk
2
451
Member Avatar for alexmejia92

[QUOTE=nanosani]#include <stdio> // stdio is the newer version of stdio.h[/QUOTE]ITYM <cstdio>

Member Avatar for Dave Sinkula
1
84
Member Avatar for alexmejia92

[code]#include <stdio.h> int main(void) { int x = 6, y = 2 * x * x * x + 5; [color=Red]printf("x = %d, y = %d\n", x, y); return 0; }[/color] /* my output x = 6, y = 437 */[/code]Man... open a book.

Member Avatar for Killer_Typo
0
115
Member Avatar for alexmejia92

[QUOTE=nanosani]c) y = 2 * (x ^3) + 5;[/QUOTE]Why do you exclusively OR x with 3? You may be interested in the [url="http://www.rt.com/man/pow.3.html"]pow[/url] function.

Member Avatar for Chainsaw
1
328
Member Avatar for Brent_Ritterbec

[QUOTE=XianBin]main() function is have tow paras like this : argv[], argc int main(argv[],argc).[/QUOTE]ITYM[code]int main(int argc, char *argv[])[/code][QUOTE=XianBin]you can confirm if user input "<" character in DOS prompt.while argv[] was contain a "<" char , you can create a file and save input strings in it.[/QUOTE]Redirection will not pass the redirection …

Member Avatar for Chainsaw
0
160
Member Avatar for Mahen

[QUOTE=Mahen]Hi everyone, i wanted my program to create another small program, but it stopped at "\x00", why and what can i do. Thnaks #include <stdio.h> int main() { FILE *out; out = fopen("c:\\cpy.exe", "wb"); fprintf(out, "\xCD\x21\x00\xCD\x21"); fclose(out); return 0; }[/QUOTE]Because "\x00" terminates the string.

Member Avatar for Chainsaw
0
175
Member Avatar for Sukhbir

Increment the object pointed to by [font=Courier New]p[/font], then increment the pointer [font=Courier New]p[/font] (point to the next object).[code]#include <stdio.h> int main(void) { char text[] = "1b#", *p = text; printf("text = \"%s\", p(%p) = \"%s\", *p = '%c'\n", text, (void*)p, p, *p); ++*p++; printf("text = \"%s\", p(%p) = \"%s\", …

Member Avatar for XianBin
0
139
Member Avatar for Mahen

How To Write Dangerous Code 101[CODE][url="http://www.eskimo.com/%7Escs/C-faq/q12.23.html"]gets[/url] (pass);[/CODE]

Member Avatar for Dave Sinkula
0
177
Member Avatar for Asif_NSU

One way:[code]#include <stdio.h> int main(void) { int a,b; char line [ BUFSIZ ]; for ( ;; ) { fputs("Enter two integer: ", stdout); fflush(stdout); if ( fgets(line, sizeof line, stdin) ) { if ( sscanf(line, "%d%d", &a, &b) != 2 ) { return 0; } printf("a = %d, b = …

Member Avatar for Dave Sinkula
0
95
Member Avatar for Sukhbir

[code]char str[] = "\12345s\n";[/code]This is equivalent to the following.[code]char str[] = {0123,'4','5','s','\n','\0'};[/code]The array has six elements, each of one byte in size -- so [font=Courier New]sizeof[/font] reports the array size as 6.

Member Avatar for Dave Sinkula
0
136
Member Avatar for mpkhadloya

[url=http://www.ecst.csuchico.edu/~beej/guide/net/]Beej's Guide to Network Programming[/url]

Member Avatar for nallahp
0
155
Member Avatar for Brent_Ritterbec

[code]if(c == ([color=Red]SPACE || '\n'[/color])) { if(c == SPACE) space++; if(c == '\n') newline++; } else other++; }[/code]The highligted code likely is not what you intend: it is a logical OR of [font=Courier New]' '[/font] with [font=Courier New]'\n'[/font] -- which results in true, a value of 1 (not the character …

Member Avatar for Brent_Ritterbec
0
324
Member Avatar for kohkohkoh
Member Avatar for kohkohkoh
0
79
Member Avatar for iamboredguy

[QUOTE=iamboredguy]I'm trying to use sequential binary file editing in C++. I use a temporary file. I have to make the changes in the file by storing the modified data in the temp file. Then I delete the original file and rename the temp as the original. The problem is the …

Member Avatar for iamboredguy
0
107
Member Avatar for Sukhbir

[QUOTE=Chainsaw]Postfix ++ has a higher precedence than prefix *.[/QUOTE]I think that [url="http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=990j7i%24u9%241%40elf.bsdi.com&rnum=5"]this explanation[/url] is a little more detailed.

Member Avatar for Chainsaw
0
141
Member Avatar for yeohsli

for (int k=0; k<=7; k++) if (a[k] > a[k+1]) You're going off the end of the array. for (int k=0; k<7; k++) if (a[k] > a[k+1])

Member Avatar for yeohsli
1
92
Member Avatar for wild_potatos

[QUOTE=wild_potatos]Hi guys / girls i am new in this forum and i hope you could help me in this problem. i programmed a link list which stores some information one of them is strings and i entered them using the function gets(); instead of scanf(); to enable the program to …

Member Avatar for Dave Sinkula
0
229
Member Avatar for sonix

[code]#include <stdio.h> #include <string.h> int main(void) { int r, c, rows, cols; const char filename[] = "file.txt"; FILE *file = fopen(filename, "r"); if ( file ) { if ( fscanf(file, "<matrix> rows = %d; ", &rows) == 1 && fscanf(file, "cols = %d; ", &cols) == 1 ) { for …

Member Avatar for Dave Sinkula
0
463
Member Avatar for RITZY_G

>can u please xplain' wat this error means: Quite often you get this when you prototype a function, but never define it.

Member Avatar for Dave Sinkula
0
148
Member Avatar for hail2dthief

[url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686&id=1043284392[/url]

Member Avatar for hail2dthief
0
405
Member Avatar for Sukhbir

>why can someone explain me You are comparing [font=Courier New]signed[/font] and [font=Courier New]unsigned[/font] values. The [font=Courier New]signed[/font] value gets promoted to an [font=Courier New]unsigned[/font] value for the comparison and ends up being very large.

Member Avatar for Dave Sinkula
0
132
Member Avatar for Mahen

Microsoft-specific [url="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/pragm_6.asp"]pragmas[/url] need not work anywhere but with a Microsoft toolchain.[code]#pragma comment(lib, "ws2_32")[/code][quote="Mahen"]I use the LCC compiler and linker on windowsXP.[/quote]What does the LCC documentation say about linking to specific libraries?

Member Avatar for Dave Sinkula
0
248
Member Avatar for kalinga

[url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046134349&id=1043284351[/url]

Member Avatar for Dave Sinkula
0
220
Member Avatar for Sukhbir

[code]#include<iostream.h> // [url="http://www.cpp-home.com/forum/viewtopic.php?t=252"]deprecated header[/url] void main() // [url="http://www.eskimo.com/%7Escs/C-faq/q11.12.html"]wrong[/url], [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044841143&id=1043284376"]wrong[/url], [url="http://www.research.att.com/%7Ebs/bs_faq2.html#void-main"]wrong[/url], [url="http://www.cpp-home.com/forum/viewtopic.php?t=266"]wrong[/url], [url="http://www.eskimo.com/%7Escs/readings/voidmain.960823.html"]wrong[/url], [url="http://users.aber.ac.uk/auj/voidmain.shtml"]wrong[/url] { cout<<"hello"; // [url="http://www.eskimo.com/%7Escs/C-faq/q12.4.html"]a similar issue in C[/url] }[/code][QUOTE=Sukhbir]//IF WE COMPILE THIS PROGRAMME IT WILL NOT PRINT HELLO ON U'R SCREEN.TELL ME WHY & TELL ME PROCEDURE HOW IT PRINT USING COUT IN VC++[/QUOTE]You do not end …

Member Avatar for stg110
0
280
Member Avatar for Nexxuz

I'd say it depends on what you intend on what you want to do with a language. It helps, however.

Member Avatar for Killer_Typo
0
108
Member Avatar for Frogstar

[QUOTE=Frogstar]So it's only counting the first number from DB.txt, ie not updating the 'correct' string in the comparison if statement, and i don't understand why not, seeing as it's updating it in the cout statement. Any ideas?[/QUOTE]It looks to me like you are finding a value [font=Courier New][i]correct[/i][/font] from [font=Courier …

Member Avatar for Dave Sinkula
0
150
Member Avatar for Sukhbir

[QUOTE=freesoft_2000]fflush(stdin); // This is to flush the input[/QUOTE]Wrong! [url="http://www.eskimo.com/~scs/C-faq/q12.26.html"]http://www.eskimo.com/~scs/C-faq/q12.26.html[/url]

Member Avatar for stg110
0
106
Member Avatar for tnorton

Could you show more of the code? Specifically the actual declarations for the variables would be helpful. I find no such issue with this minimal code sample. [code]#include <stdio.h> int main(void) { float ovrh = 1.0F, wr = 1.0F, z = 1.0F, Fees = ovrh + (wr * z); printf("Fees …

Member Avatar for Dave Sinkula
0
332
Member Avatar for edison

Use a loop.[code][color=Red]#include <iostream> using std::cout; using std::cin; using std::endl;[/color] [color=Red]int [/color]main() { [color=Blue]for ( ;/* your condition here*/; )[/color] [color=Blue]{[/color] float x,y; cout << "Please enter one number "; cin >> x; y = x * x; cout << "The square of the number you enter is " << …

Member Avatar for freesoft_2000
0
155
Member Avatar for kohkohkoh

>and when i enter a password... i want it to reveal the code in this form "*****". How should i do that? A [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686&id=1043284392"]C example[/url] (second snippet).[url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686&id=1043284392"] [/url]

Member Avatar for Pikachu
0
142
Member Avatar for Asif_NSU

[url="http://www.codeproject.com/buglist/linkererrors.asp?df=100&forumid=15354&exp=0&select=548037"]Here[/url] and [url="http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_21035721.html"]here[/url] it mentions something like this:[quote]Check your project settings under 'C++|Code generation'. That should read "Multithreaded DLL"[/quote][url="http://www.google.com/search?q=error+LNK2005+debug+release"]Other possibilities[/url].

Member Avatar for Chainsaw
0
354
Member Avatar for fang221914

Perhaps you missed the [url="http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2"]announcement[/url] at the top of the page.

Member Avatar for alc6379
0
105
Member Avatar for ellisrn

It could look so much nicer if you wrapped your code with CODE tags. if ( i = 1 ) { if ( j = 1 ) { if ( k = 1 ) Assignment is `=`, comparison is `==`. And array indices are zero based.

Member Avatar for Dave Sinkula
0
179
Member Avatar for Mahen

Integers are not floating point. Using [font=Courier New]sscanf[/font] to convert the command line text is my recommendation; with error checking, and using the [font=Courier New]+[/font] symbol itself, it might be as follows. [code]#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { double a, b; if ( argc > 3 …

Member Avatar for Dave Sinkula
0
99
Member Avatar for Mahen

First, [url="http://www.eskimo.com/%7Escs/C-faq/q12.20.html"]avoid scanf[/url]. Second, use a floating point type to enter a floating point value.[code]#include <stdio.h> int main() { [color=Red]double[/color] number; fputs("Enter number: ", stdout); fflush(stdout); if ( scanf("[color=Red]%lf[/color]", &number) == 1) { printf("number = %g\n", number); } return 0; } /* my output Enter number: 23.45 number = 23.45 …

Member Avatar for Dave Sinkula
0
182
Member Avatar for stg110

I believe you want to use a [url="http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-38.12"]forward declaration[/url].

Member Avatar for stg110
0
94
Member Avatar for kohkohkoh

Something like this? #include <iostream> void disp(int a[][[color=Red]2[/color]]) { for ( int i = [color=Red]0[/color]; i [color=Red]< [color=black]3[/color][/color] ; i++ ) [color=Red]{[/color] for ( int j = [color=Red]0[/color]; j [color=Red]< [color=black]2[/color][/color] ; j++ ) { std::cout << a[i][j] [color=Red]<< ' ';[/color] } [color=Red]std::cout << std::endl;[/color] [color=Red]}[/color] } int main() { …

Member Avatar for Dave Sinkula
0
97
Member Avatar for Sukhbir

[url="http://www.eskimo.com/%7Escs/C-faq/q3.3.html"]http://www.eskimo.com/~scs/C-faq/q3.3.html[/url] [url="http://www.eskimo.com/%7Escs/C-faq/q3.8.html"]http://www.eskimo.com/~scs/C-faq/q3.8.html[/url] [url="http://www.eskimo.com/%7Escs/C-faq/q3.1.html"]http://www.eskimo.com/~scs/C-faq/q3.1.html[/url] [url="http://www.eskimo.com/%7Escs/C-faq/q3.9.html"]http://www.eskimo.com/~scs/C-faq/q3.9.html[/url] [url="http://www.eskimo.com/%7Escs/C-faq/q3.2.html"]http://www.eskimo.com/~scs/C-faq/q3.2.html[/url]

Member Avatar for alc6379
0
115
Member Avatar for taimour

[QUOTE=chound]#include<iostream.h> //header file for basic input and output functions void main() //main function { cout<<"Hello world"<<endl; //prints out "Hello world" and endl clears the stream }[/QUOTE][list=1] [*]Please use code tags when posting code ([code][/code]). [*][font=Courier New]#include<iostream.h>[/font] is decprecated. [*][font=Courier New]void main()[/font] is incorrect for a hosted implementation. [/list]

Member Avatar for Dave Sinkula
0
93
Member Avatar for policeachan

This is because when you have several modules, you don't want the code to be in more than one place. The [font=Courier New]#include[/font] directive essentially copies the contents of the file into your source module. If you have 5 modules that each include a header that contains actual code, you …

Member Avatar for Dave Sinkula
0
139
Member Avatar for merlin208

Let's say you want an interactive program to input two numbers, add them together, and display the result. The user types some text, right? Was that text actually representing a valid number? Or do you just blindly add two values that may or may not be there. Data validation, in …

Member Avatar for Chainsaw
0
146
Member Avatar for andremc

>it's fine when i run only one of the sorts, but if i run both, moves comes out to 0. If you've sorted the list, just how many swaps do you think you'd need to sort the list?

Member Avatar for andremc
0
1K
Member Avatar for Sukhbir

I believe it is invalid syntax. Did you mean a declaration for an array of pointers returning [font=Courier New]int[/font] and taking no parameters? [code]#include <iostream> int foo() { std::cout << "foo\n"; return 0; } int bar() { std::cout << "bar\n"; return 0; } int main() { int [color=Red]([/color]*p[][color=Red])[/color]() = {foo,bar}; …

Member Avatar for FireNet
0
83
Member Avatar for matt768

[QUOTE=matt768]I don't know much about c programming at all, as I have only been doing it for about five hours, any help would be much appreciated[/QUOTE]Post your attempt with any error messages and the specific questions you have. Or read [url="http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2"]this[/url].

Member Avatar for Chainsaw
0
78
Member Avatar for icono
Member Avatar for steelers_fan

Anyone who [i]recommends[/i] [font=Courier New][url="http://www.eskimo.com/~scs/C-faq/q12.26.html"]fflush(stdin)[/url][/font] is awarded instant newbie status. [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351"]It is not correct[/url], and [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044873249&id=1043284392"]there are other ways to accompish its intended effect[/url].

Member Avatar for steelers_fan
1
208
Member Avatar for Tex_Tootell

#1 [url="http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=C2143&s=1&swc=4"]C2143[/url] #2 [url="http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=C2501&s=1&swc=4"]C2501[/url] #3 [url="http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=C3265&s=1&swc=4"]C3265[/url] #4 [url="http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=C1010&s=1&swc=4"]C1010[/url]

Member Avatar for Tex_Tootell
0
170
Member Avatar for Sukhbir

[size=2][url="http://pw2.netcom.com/%7Etjensen/ptr/pointers.htm"][b]A TUTORIAL ON POINTERS AND ARRAYS IN C[/b][/url] [url="http://pw2.netcom.com/%7Etjensen/ptr/ch8x.htm"]CHAPTER 8: Pointers to Arrays[/url][/size]

Member Avatar for Dave Sinkula
0
65
Member Avatar for Sukhbir

[code]char a[]={'a','b','c',d'}; int b[]={1,2,3,4,5}; printf("%d %d",&a[3]-a,&b[3]-b};[/code] You are taking the difference between pointers; the result is the number of objects between the two addresses. There are three objects between element 0 and element 3, regardless of the size of the objects.

Member Avatar for Naveen
0
166

The End.