1,088 Posted Topics

Member Avatar for speedy94519

speedy94519> do you guys any suggestions how i could return the arrays contents??? Yes, make str3 to point to the destination. Work with that pointer and then return destination. [CODE]char* strcat(char *to, const char* from) { /* Declarations */ int length_1,length_2,i; char *str3; /* Get the length of each string …

Member Avatar for anonymous alias
0
361
Member Avatar for Dave Sinkula

[QUOTE=ZZucker;509676]...or just falls asleep a lot like Ronald Reagan did? [/QUOTE] That's wisdom in action. Try to change what you can and what you can not, well, sleep it over.

Member Avatar for jephthah
0
6K
Member Avatar for llemes4011

[QUOTE=llemes4011;1217185]Thanks a lot! =) One question - is C/C++ used to program the Arduino Board? or does it have it's own language?[/QUOTE] It has its [URL="http://arduino.cc/en/Reference/HomePage"]own[/URL] language based on C/C++

Member Avatar for llemes4011
0
117
Member Avatar for serkan sendur

I nominate this the most entertaining thread of the month. ;) By the way, if you donate you will be consider special. ...Now if I only could figure who's essential

Member Avatar for jephthah
1
366
Member Avatar for jsphb9000

[CODE]char quit; scanf("%[COLOR="Red"]s[/COLOR]", &quit);[/CODE] Take a look at that format specifier and find out why is wrong. [CODE]while (quit == 'N' || quit =='n');[/CODE] That translates into English to something like this: Loop for as long as quit is equals to a N or n Why would that be wrong?

Member Avatar for Aia
0
310
Member Avatar for chrisfrmatl

[QUOTE=chrisfrmatl;1216089]Hmmmm.. Now its saying segmentation fault[/QUOTE] That's not a surprise! [CODE]struct dirent *dirEntry;[/CODE] That's a pointer to some structure of type direct, but you do not set any memory apart before trying to access it and assigning to it. On top of that, there are plenty of warnings that the …

Member Avatar for Salem
0
410
Member Avatar for thomasekugm

[URL="http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/"]sscanf()[/URL]

Member Avatar for thomasekugm
0
166
Member Avatar for lionaneesh

[QUOTE=gerard4143;1214484]Now I didn't know that. I guess that's why I keep coming back.[/QUOTE] sizeof is an unary operator and not a function, the parenthesis are only necessary for precedence sake. [B][Edit:][/B] Missed this point from Salem [QUOTE]> 4. sizeof() ; function says it all . It means size of the …

Member Avatar for lionaneesh
-1
401
Member Avatar for P3druh77

> Hi... i have a little problem on my code... What's the little problem? You did state a question, nor did you point what are you having problem with. Consider just the following in main. int main(int argc, char *argv[]) { ALUNO alunos; FILE *fp; int tam==3; fp=fopen("example.txt","r"); alunos = …

Member Avatar for Aia
0
245
Member Avatar for endritius

[I]endritius>[/I][B] Also isn't that the declaration before main of the function is supposed to tell the compiler that a function below main has to be linked and there should be reserved three places in memory for three variables. [/B] Not exactly. A function prototype is a concept "borrowed" from other …

Member Avatar for endritius
0
236
Member Avatar for Rob E

A couple questions and a statement. Is your compiler or you linking the math library for the pow() function? What do you enter at the first prompt? A number (integer) or the label? Do you enter `blue' or do you enter `6'? Here's the statement. You need to uncomment the …

Member Avatar for Rob E
0
446
Member Avatar for moroccanplaya

[QUOTE=moroccanplaya;1212949]i dont understand you[/QUOTE] [QUOTE=moroccanplaya;1212950]cant you help me[/QUOTE] He's trying to help you think by yourself. It is just an error in your printf() format. You are missing arguments. [CODE]printf(" [COLOR="Red"]%d [/COLOR]is larger [COLOR="Red"]%d[/COLOR]"); [/CODE] You have two format tags %d but you do not provide specifiers. It should be …

Member Avatar for jephthah
0
120
Member Avatar for wackozacko

>>while(fgets(varline, 128, inf) != NULL) varline can hold only 8 characters including the '\0', but you are saying to fgets() go and fetch 128. sizeof operator can help you to avoid these pitfalls. [B][I]e.i.[/I][/B] [CODE]fgets( varline, sizeof varline, inf) != NULL )[/CODE] By the way, in C89 the [ICODE]char program[size][8];[/ICODE] …

Member Avatar for Aia
0
2K
Member Avatar for johndoe444

[QUOTE=Ancient Dragon;1207577]That doesn't work [code] int main(){ char R[255] = {0}; int s, e, n; scanf(" %n%s%n %d", &s, R, &e, &n); int len = e - s; cout << "len = " << len << '\n'; return 0; } [/code][/QUOTE] Pay attention! This is not the C++ forum

Member Avatar for sourabhtripathi
0
338
Member Avatar for gerard4143

[CODE]*(unsigned int*)&recvline[0] = 11111; *(unsigned int*)&recvline[sizeof(unsigned int)] = 22222; /*this section*/ *(void(**)(void))&recvline[2 * sizeof(unsigned int)] = (void(*)(void))&myhello; /*this section*/[/CODE] Casting is not for l-value. Only for r-value.

Member Avatar for gerard4143
1
180
Member Avatar for The Dude
Member Avatar for tcstom

realloc() only works with memory that has been previously allocated with malloc(), calloc() or realloc() [CODE]ProtocolReceiveBuffer = realloc(ProtocolReceiveBuffer, (rows)*sizeof(unsigned int*));[/CODE] It is not recommended to use the same pointer to reallocate memory. If it fails you have lost the point to that memory creating a memory leak.

Member Avatar for tcstom
0
4K
Member Avatar for leegeorg07

>But i want to round the square-rooted numbers to about 6 digits e.g. 5.12345. How can this be done? Take a look at round()

Member Avatar for vegaseat
0
491
Member Avatar for lllllIllIlllI

[QUOTE=Narue;1147668][B]>Nobody twisting your arm to click on the thread, is there?[/B] In theory, excessive posts could fill up the database and slow the site down enough to cost Dani more money in maintaining the status quo, and in turn she could start charging subscriptions. Every "I HAZ XXX POSTS D00D!!11" …

Member Avatar for bumsfeld
10
248
Member Avatar for SHENGTON

I understand you are learning the language, and that you copied the source from someone else. While much can be learned by emulating other people's code, an invisible trap is constantly waiting for you while you are obtaining experience. For example: [ICODE]fflush(stdin);[/ICODE] That's something you should never emulate. It is …

Member Avatar for vsiddharthv
0
924
Member Avatar for seaman34

[QUOTE=seaman34;1188134]if i add printf("%s",temp) line 16 the output is what I want e-r-e-t-z-n-e-h-e-d-e-r-e-t i just need to copy temp back to src so line 9 work as it should. line 20,21,22 is what i got from the work. May it work if i use strcopy?[/QUOTE] If you want the source …

Member Avatar for p.y.
0
157
Member Avatar for 123a
Member Avatar for adrawat

[QUOTE=Ancient Dragon;1191143]Create an array of pointers, then read each line and add to the array [code] [...] [/code] Now put the above in a loop so that it reads the entire file. Increase the array size if needed so that it will hold all the lines in the file.[/QUOTE] Perhaps, …

Member Avatar for WaltP
0
300
Member Avatar for DCvonB

[QUOTE=UncleLeroy;1190392]The assignment says to allocate in the function, and free() it in main. [CODE] void get_days_in_month(int **days, int year) { int *array = malloc(sizeof(int) * 5) ; /* Set the output variable */ *days = array ; /* do not increment either pointer (days or array) */ array[0] = 31 …

Member Avatar for Aia
0
152
Member Avatar for Cheran

[QUOTE=Cheran;1190482][...] My output should be C:\windows\1.jpg" i dont know where to correct the program.waiting for a soon reply thanks cheran[/QUOTE] Start here: [CODE]char* my_string( char* dest,[COLOR="Red"]char *c[/COLOR])[/CODE] There's not a need for another string if you are not using it. [CODE]strcat(dest,[COLOR="Red"]*str2[/COLOR]); [/CODE] Incorrect argument. str2 is the correct one. However …

Member Avatar for Aia
0
142
Member Avatar for geekgirl2011

[CODE=C]typedef struct { char name[10]; int weight; int neutered; } CAT;[/CODE] That fulfills requirement A Requirement B is not found at this point. Requirement C is not correct. [QUOTE]C. Write a function called printCat that outputs a CAT neatly. Pass the CAT by REFERENCE. Call your function passing in pMax …

Member Avatar for jephthah
0
202
Member Avatar for tquiva

[CODE]scanf("%s", [COLOR="Red"]&[/COLOR]input);[/CODE] scanf("%s", input); (notice that there's no &) does not add the new line representing the ENTER/RETURN key. Therefore, the string obtained into input never contains a '\n'. On the other hand [CODE]fgets(input, sizeof input, stdin);[/CODE] starts reading until it reaches one less than the sizeof input or the …

Member Avatar for Aia
0
3K
Member Avatar for vino4all

[QUOTE=jephthah;1184639]uh... not so much :) [code]#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { FILE *fp_source, *fp_dest; char oneByte; /* WARNING: this does ZERO error checking!! */ fp_source = fopen(argv[1], "rb")); fp_dest = fopen(argv[2], "wb")); while(!feof(fp_source)) { oneByte = fgetc(fp_source); fputc(oneByte, fp_dest); } fclose(fp_source); fclose(fp_dest); return 0; }[/code] .[/QUOTE] …

Member Avatar for jephthah
0
246
Member Avatar for johndoe444

[QUOTE=johndoe444;1181503]for the above command what values are passed to the format string %s and %p inside the printf and how?[/QUOTE] man find; line 988 and line 993 will tell you.

Member Avatar for Aia
0
69
Member Avatar for johndoe444
Member Avatar for Aia
0
57
Member Avatar for geekgirl2011
Member Avatar for twentylemon

[CODE]'dir /b /a[COLOR="Red"]-[/COLOR]d'[/CODE] The hyphen will do the opposite to what you want [ICODE]DIR /B /A:D [/ICODE]will list only directories. Nevertheless, you don't need any of that. Following your logic and given information. [CODE=batch]FOR /D %%A IN (*) DO ( FOR /D %%B IN (%%A\*) DO ( if not exist …

Member Avatar for Aia
0
123
Member Avatar for doom5

At some point it has to stop, and it does when it reach memory that doesn't like been overwritten. [CODE]while( i != j)[/CODE] That never stops. i and j never are the same.

Member Avatar for girishn
1
143
Member Avatar for johndoe444

[QUOTE=johndoe444;1178041]I have to press :q twice or more that I don't like.[/QUOTE] You are barking at the wrong tree. This vi/vim questions are better answered by going to the right source. [url]http://www.vim.org/huh.php[/url] [ICODE]:wqall [/ICODE]is the answer to this one.

Member Avatar for Aia
0
70
Member Avatar for johndoe444

[QUOTE=johndoe444;1177258]There are so many information dispersed in so many places. And most of them kind of cover the same set of topics like ps, cd, pwd, chmod, chown, etc. But there are so many things to learn. Really need some advice how to muster all the knowledge.[/QUOTE] Get the current …

Member Avatar for Aia
0
163
Member Avatar for johndoe444

johndoe444> Is that all? Not even close. Open a bash terminal. Press TAB twice. Notice how many it can display. Enter y and start reading.

Member Avatar for Aia
0
66
Member Avatar for johndb

Use a FOR loop example: move any directory that starts with [B]test[/B] in its name to a directory named newfolder. [CODE]FOR /D %A IN ("test*") DO MOVE %A newfolder[/CODE] [ICODE]/D[/ICODE]: is for directories [ICODE]%A[/ICODE]: when used in a script, it must be doubled [ICODE]%%[/ICODE] Further reading about [URL="http://ss64.com/nt/for.html"]FOR[/URL]

Member Avatar for Aia
0
109
Member Avatar for spursfan2110

[QUOTE]For my assignment, I have download a .txt file from my prof's webpage, and then have my program open it. The file, when opened in a web browser, appears as follows:<br /> <br /> 87.0<br /> 94.5<br /> 55.6<br /> 88.0<br /> 82.0<br /> 91.0<br /> etc.<br /> <br /> …

Member Avatar for spursfan2110
0
113
Member Avatar for nupurashi

[QUOTE=nupurashi;1173776]adak i am not doing so in development of a software .. these type of questions were there in google's interview[/QUOTE] The right answer is. This invoke undefined behavior. If you need a why, you need to learn about sequence points.

Member Avatar for WaltP
0
101
Member Avatar for Etherwind

Etherwind> I've fed it all sorts of input trying to break the while condition, but no dice. The only char input that will stop the while loop is the newline or ENTER key, according to your code. But you wrote it incorrectly. Instead of [ICODE][COLOR="Red"]"[/COLOR]\n[COLOR="Red"]"[/COLOR][/ICODE] it must be [ICODE][COLOR="Green"]'[/COLOR]\n[COLOR="Green"]'[/COLOR][/ICODE]. There's …

Member Avatar for WaltP
0
104
Member Avatar for bohongtw

bohongtw > i just wanna learn how to start ok! Start by creating an empty file [CODE]touch myfirstscript.csh[/CODE] Now open the file with your editor of choice [CODE]vi myfirstscript.csh [/CODE] After that, write in the first line Either [CODE]#!/usr/bin/csh[/CODE] or [CODE]#!/bin/csh[/CODE] Depending where the c-shell program lives in your system …

Member Avatar for Aia
0
174
Member Avatar for lionaneesh

[B]jephthah>[/B] it appears that you can't protect buffer overruns, like you can with fgets... scanf() accepts width. You can take advantage of it to prevent buffer overruns. [CODE=c]char buffer[10]; scanf("%9[^\n]", buffer); /* read nine chars or until it finds a new line, whichever is first */[/CODE] Must be aware that …

Member Avatar for jephthah
1
332
Member Avatar for unbrknchane

[QUOTE=unbrknchane;1170584]THANKS! What exactly is GUI? I am on my school computer right now but will download MinGW when i get home. also g++ ? sorry I am a beginner programmer.[/QUOTE] [URL="http://en.wikipedia.org/wiki/G%2B%2B"]g++[/URL] [URL="http://en.wikipedia.org/wiki/Graphic_user_interface"]GUI[/URL] Searching for the terms in any search engine will help you to avoid to explain that you are …

Member Avatar for jephthah
0
240
Member Avatar for alcx88

[QUOTE=jephthah;1169728]it takes user input (from keyboard) by using stdin, like so: [code]char inputStr[MAX_STR_LEN]; fgets(inputStr, sizeof(inputStr)-1), stdin);[/code] ... is this what youre asking? [/QUOTE] A little note concerning [ICODE]sizeof(inputStr)[COLOR="Red"]-1[/COLOR][/ICODE] There's not need to make room (-1) for the nul terminator. fgets() does that already. It will always accommodate the [ICODE]'\0' [/ICODE] …

Member Avatar for jephthah
0
2K
Member Avatar for tquiva

[ICODE]for(i [COLOR="Red"]=[/COLOR]= 0; word[i]; i++)[/ICODE] better [ICODE]for (i = 0; word[i] != '\0'; i++)[/ICODE] [ICODE]char word[50] = [COLOR="Red"]" "[/COLOR];[/ICODE] better [ICODE]char word[50] = {[COLOR="Red"] '\0' [/COLOR]};[/ICODE] [ICODE]scanf("[COLOR="Red"]%s[/COLOR]", [COLOR="Red"]&[/COLOR]word);[/ICODE] better [ICODE]scanf("%[COLOR="Red"]49[/COLOR]s", word)[/ICODE] Ponder about why.

Member Avatar for hkdani
0
167
Member Avatar for smi ensi

[QUOTE=Adak;1168868]Here's some important things to do: 1) This is predominately an English language board. Translate your program into English, and re-post it. [/QUOTE] That's not a requirement for getting help here. The post was made in as good English as the OP could produce. The code doesn't have to be …

Member Avatar for jephthah
0
110
Member Avatar for abhay_tanu

[QUOTE=abhay_tanu;1167868]Hi Through shell script we put a file on remote sever. After putting file on that server it goes into inbox folder and it appends a hash code to file name. So when getting back the same file from inbox folder it is giving me following error. [COLOR="Red"] /inbox/TESTFILE*: No …

Member Avatar for abhay_tanu
0
237
Member Avatar for paragj

You must post the code that you have done. You'll get no help if you don't show what you have done so far. Tell us as well where did you get stuck. Don't dump just the code and expect someone to fix it for you.

Member Avatar for Aia
0
106
Member Avatar for tquiva

[QUOTE=pranaykumar;1168084]u can use this code. only problem is that u need to start input with a blankspace or else 1st digit is lost. I f u can remove this bug do tell me. #include<stdio.h> main() { int i=0,a[4]; printf("enter the min for grades\n"); while((getchar()!='\n')) scanf("%d",&a[i++]); printf("\n"); for(i=0;i<=3;i++) printf("%d\t",a[i]); }[/QUOTE] Next …

Member Avatar for Aia
0
154
Member Avatar for sharpcon

[QUOTE=sharpcon;1168073]In the code snippet: [CODE=C] int Z; boolean ParsedOk; ParsedOk = sscanf( CommandLine, "%i", &Z ) == 1; [/CODE] [...] How can I detect (and reject) such malformed numerical input?[/QUOTE] Check for trailing input as well. [CODE=c]if (sscanf(CommandLine, "%d%c", &Z, &ch) == 2 && (ch == '\n' || ch == …

Member Avatar for Aia
0
111

The End.