949 Posted Topics

Member Avatar for netuse

That's not how the forum works. We aren't a "do your homework for you" forum. We are a free "help you out when you get stuck on your homework, and show real effort", forum. [B]It's all up to you to get the project started[/B]. It's a pity you have no …

Member Avatar for asitmahato
-1
93
Member Avatar for DJWK

Books are prone to doing this ( putting function definitions before main() ), because it saves them space in every program they print. I always like main() first, then all functions go in alphabetical order, with function declarations in global space, unless the function is used entirely as a helper …

Member Avatar for Adak
0
149
Member Avatar for kylelendo

Make your output screen a tiled window, before you start the program. If you need to see more of it, use your mouse, only. Obviously, you can't leave keystrokes in the input buffer, and not have it affect your program, which relies on the keyboard input buffer.

Member Avatar for Narue
-1
233
Member Avatar for swaraj@MT

Off hand, I'd say use a two dimension (rows and columns) array of chars. Put the filename in the first chars, and then a space, and follow that with the keywords. Each keyword also separated by a space. FileName1 dogs type hounds terriers setters herding toys FileName2 horses type Quarterhorse …

Member Avatar for Adak
0
210
Member Avatar for amrita111

printf returns the number of chars printed, and you didn't print any objects, so it would return a negative number, as an error IF your compiler allowed it to compile. Perhaps you were thinking of: [code] if((ch = printf(something here)) > 0) //semi-colon or other code goes here [/code] That's …

Member Avatar for Narue
0
220
Member Avatar for Rupindersingh

DOS had a path environmental variable, in a file named "config.sys". Windows has something similar, sometimes it uses config.sys, and sometimes it uses another file, depending on the version. The registry also has data on this. Best answer is to look up PATH in your Windows help, which will have …

Member Avatar for Adak
0
148
Member Avatar for fullarmorzz

[CODE] #include<stdio.h> #include<conio.h> #include<string.h> int x; char name[20]; main() { printf("Exercise no. 10 ESN 211-9A MWF 7:30-9;30\n\n"); printf("Enter your age:\n"); scanf("%d",&x); if (x<18) printf("UNDERAGE!\n\n"); else if (x==18) printf("STUDENT LICENSE POSSIBLE\n\n"); else printf("PROFESSIONAL LICENSE AVAILABLE\n\n"); printf("Enter the result of your drug test: \n"); scanf("%s",&name); /* C doesn't support strings as basic …

Member Avatar for Onlineshade
0
123
Member Avatar for damaia

When you open a file, you receive a file position pointer (part of the FILE *, but not the whole thing). The file pointer has the address of the first byte of the file. If you increment that address, you can access any byte in the file, in sequential mode. …

Member Avatar for Adak
0
1K
Member Avatar for SHENGTON

Your functions are not really functions, since you put a semi-colon on the end of their first line, in your program. I've fixed that for you, and made some important notes in this code, for you. The function main() should not be called, inside your program, as noted. Also, all …

Member Avatar for Adak
0
496
Member Avatar for Ich bin würdig

Welcome to the forum, Wurdig! ;) Remove the switch case. It just makes things more difficult. You'll need two nested for loops. The outer one will range from 0 to < MaxRows. The inner for loop is for the columns in one row, and will range from 0 to < …

Member Avatar for Adak
0
231
Member Avatar for .:Pudge:.

Try "cd..", to get back to the next higher level directory (parent). After the cd, if you don't use the two dots, you should specify the directory name you want to change to. Try "dir", instead of "ls". What OS are you using?

Member Avatar for nezachem
0
206
Member Avatar for Rupindersingh

Windows puts constraints on what you can do in this regard, depending on the version of Windows you are running. You are very likely to crash either the TSR program, another program running at that time, or even Windows itself. Modern way to do this, would be to use a …

Member Avatar for Adak
0
432
Member Avatar for Mahesha999

This is your original code (in code tags, please use them): [CODE] char *dic[][40] = { "atlas", "A volume of maps.", "car", "A motorized vehicle.", "telephone", "A communication device.", "airplane", "A flying machine.", "", "" /* null terminate the list */ };[/CODE] The square brackets here: dic[B][COLOR="Red"][][/COLOR][/B][40], are not necessary. …

Member Avatar for Mahesha999
0
143
Member Avatar for 1150

[B]Welcome to the Forum, 1150! ;)[/B] Scanf() leaves a newline in the keyboard buffer, and it's throwing a monkey wrench into gets(). The fix is to add this, right after the scanf() line of code: [CODE]getchar(); //pulls off one (newline in this case), char.[/CODE]

Member Avatar for Adak
0
116
Member Avatar for aloi93

Your logic should answer the kid's annoying questions on long trips: "Are we there yet?" [code] while(1) { if distance == goal) { stopWalking(); printf("Goal reached\n"); break; }else { takeAstep(); //assumes each step is 1 meter printf("I have %d more meters to cover\n", --distance); } } [/code] In humans, walking …

Member Avatar for Adak
0
149
Member Avatar for amrita111

Try it, it won't bite you. ;) To learn to be a problem solver, you have to explore the world of code - roses and thorns, as well.

Member Avatar for jnawrocki
0
99
Member Avatar for sydsine

Are you using a C compiler, or a C++ compiler? In C++, &n would be a reference to n. I'm unsure how a C++ compiler would handle that reference, in a declaration. In C, a declaration of &n is an error. These are the errors I get from my Pelles …

Member Avatar for himgar
0
326
Member Avatar for bubbinos

Welcome to the forum, Bubbinos! ;) Change your logic. Start with the array of numbers, being assigned to the array: [CODE] for(i=0;i<52;i++) { //eliminate repeated numbers array[i] = i; } //now pick a random card for(i=0;i<(NumPlayers * 5); i++) { j = rand() % 52 + 1; //range of 1 …

Member Avatar for Adak
0
215
Member Avatar for cse.avinash

There are two ways: 1) Use a big number library. GNU's is well known. 2) Use an int or char array. Make each element hold just one digit of the number. Write a function for each operation you want done. Yes, you might want a matching array, just to hold …

Member Avatar for TrustyTony
0
280
Member Avatar for D33wakar

Use fgets() to take in at least one line of text, at a time, into your buffer. Then use strstr() to look for the target word, in the buffer. You don't want to do this, char by char. To make it more efficient still, search for string search in Wikipedia, …

Member Avatar for Narue
0
231
Member Avatar for Jamblaster

Welcome to the forum, Jamblaster! ;) Always click on the [code ] icon and when it puts two code tags on your reply page, paste your code, between the code tags - easy to do since it puts your cursor right between them for you. All comparison sorts except for …

Member Avatar for Anuradha Mandal
0
213
Member Avatar for pinkannu

What is your field (struct member is also a field), separator? Hyphen, space, maybe both? Here's a trick: Initialize all your fields in the struct to 0 or '\0'. Print out some strings. Put a vertical line between each field, with a pencil |. Now you can loop through the …

Member Avatar for pinkannu
0
193
Member Avatar for ineedsomehelp:3

No, this something you can easily do yourself, and just involves a bit of problem solving. You NEED to develop your problem solving, or you can't program worth a darn. Work through it by hand, and see what kind of loops you're using! Put some sweat into it! ;) Don't …

Member Avatar for Adak
0
126
Member Avatar for lastbencher

If you ONLY want a C IDE and compiler for Windows only, I'd recommend Pelles C. It is ONLY for C, and ONLY for Windows (32 or 64 bit, so XP or Vista or Win7 are all fine). I like it! ;)

Member Avatar for mitrmkar
0
309
Member Avatar for Mahesha999
Member Avatar for Adak
0
147
Member Avatar for keshvari

First thing - are you getting any warnings from your compiler? And do you have your warning level turned up high? Second, try checking the return addresses that malloc is giving your pointers. Are any of them null (indicating a serious problem)? Third, cut down on the space where the …

Member Avatar for keshvari
0
131
Member Avatar for D33wakar
Member Avatar for kkanedaa

You can't compare strings - you have to compare each char, one at a time. Include string.h and use strcmp(string1, string2). strcmp(string1Name, string2Name) will return one of three values: 1) a positive number 2) zero 3) a negative number That return tells you what the comparison of strings revealed: 1) …

Member Avatar for kkanedaa
0
429
Member Avatar for yakovm

You're trying to print to the file or buffer, from within the IDE, aren't you? That's not what you want. Run it from the command line. Open a terminal (aka text window, command line interface, etc.) window. If you are not in the same directory as the exe of your …

Member Avatar for Narue
0
97
Member Avatar for Prankmore

Try this: [CODE]//Before main() define a struct with struct countries { char name[50]; int numNation; } //now make an array of these structs, in main() struct countries nations[500?]; char myNation[50]; //and read in your data from a file, into the array of structs. //Now a for loop can replace all …

Member Avatar for Prankmore
0
201
Member Avatar for SWORDfreak1

I haven't read through all the above posts, but here's my ideas: 1) Use structs for each player, and struct members (fields) for each attribute you need. 2) KISS. Don't go Rube Goldberg here! You don't need a damage attribute, because when a character is damaged, his strength or life …

Member Avatar for SWORDfreak1
0
199
Member Avatar for coril

fflush() on any input stream, like stdin, is deprecated, so it may very well not work at all. Use it on output streams only. ("Flush the toilet, not the kitchen faucet.") To pull the remaining newline char off the input stream, you can use: [CODE]getchar();[/CODE] right after the scanf() line …

Member Avatar for Narue
0
1K
Member Avatar for largedimples

This is an OOP based program, and C has no OOP support. So, you need to post this in either a Java, or maybe even a C++ forum. Definitely, not here.

Member Avatar for WaltP
0
247
Member Avatar for little_bee

Sorry, little bee, but we won't do your homework for you. This is a forum that tries to answer questions and problems relating to C. I'm sure your grade will be reviewed, and reflect the amount of work you put into it. You might try browsing through the "Computer Science" …

Member Avatar for Adak
0
128
Member Avatar for kooletz

You're trying to shove a first and a last name, into the same variable, name[]. That won't work. You can fix it easily a few different ways: [CODE]char lastname[30]; char firstname[30]; [/CODE] and then scanf() for the lastname, and for the firstname[] (or lname and fname, whatever). Or you can: …

Member Avatar for WaltP
0
184
Member Avatar for kooletz

First, decide on the appropriate data type for each input and output item. Each of them will need to be a variable (a few might be removed later, but for now, plan on one variable per item, for input and for output. All variables should be local to main(), or …

Member Avatar for YAMNA MIDHAT
0
149
Member Avatar for theCompiler

OK, this is the part of the help where YOU help US understand WTF you want. We weren't in the classroom, or heard the lecture, or read the text, or even know the teacher. First - find out what you want to do. Your info here just isn't enough to …

Member Avatar for sergent
0
289
Member Avatar for Eternal49

If you have your data in the format you want, then don't convert it any further - C'mon! ;) You can read your hex data in as a string using fgets(buffer, sizeof(buffer), filePointer); Make sure that buffer has at least two char's more than the longest string of hex. One …

Member Avatar for WaltP
0
601
Member Avatar for ZIA_JAPPA125

Zia, welcome to the forum! ;) First thing you have to know is to ALWAYS highlight your code and click on the [ code] icon in the editor window. (it won't have a space before the c). Otherwise, your code will all be squished over to the far left, and …

Member Avatar for Adak
0
140
Member Avatar for Falcon143

In Pelles C it's under the Source pull down menu, then select "view line numbers". Check around your IDE editor options, also. Not every IDE editor has this, for an option.

Member Avatar for nmaillet
0
2K
Member Avatar for poojavit

I would learn the basics of the C language first. Can't do anything without that. There are lots of C tutorials on the web, including one's for this forum, and other programming forums with a C section on them. If you just want to manipulate images, I'd use software designed …

Member Avatar for Adak
-1
119
Member Avatar for keshvari

I don't see anything obvious, but I'm not familiar with this, either. If I were starting to debug it, I'd probably start with assertions to check that all the indices are staying within their proper ranges. Then start checking the subtotals, and whether j=0 is correct, for it's initialization (or …

Member Avatar for keshvari
0
1K
Member Avatar for Prankmore

Take in the telephone number as a string. Scan over the chars, and remove any hyphens or /'s. If any char in the string is unwanted, then [CODE]for(each char from that point, to the (end -1) of the string) { assign i+1 to i, in the array } [/CODE] and …

Member Avatar for Prankmore
0
3K
Member Avatar for SVR

[QUOTE]The problem is at some distance before they pass (at t2) they will have sufficient velocity to pass each other on the next iteration (t3). At t3 the distance will not be the same as t2 causing the deceleration to be different. [/quote] You may not care what the velocity …

Member Avatar for SVR
0
147
Member Avatar for arlir

After EVERY scanf("%c...), when you are storing a char data type, add this: getchar(); Right after it. OK, the last one in the whole program, you don't need to add this line of code. What it does is remove the newline char that scanf() always leaves behind in the input …

Member Avatar for muktigeek
0
234
Member Avatar for tubby123

LevyDee is right IF the array had been sent to another function. In the function it was declared in, it will have size 10. Tubby, the union has ONLY a size big enough for the largest member. THE largest member, not the SUM of all the members. That would be …

Member Avatar for Adak
0
84
Member Avatar for drdaco
Member Avatar for Na'Vi

In C, the name of the array, is ALMOST the same thing, as a constant pointer - and it points to the first element of the array - array[0]. So [CODE]char a[] = "Hello there.";[/CODE] now the address of a, is the address of a[0], and a string operation includes …

Member Avatar for Narue
0
80
Member Avatar for jodzjcm

userinput[2] == userinput[2] ?? C'mon! ;) When you have a complex line of code, break it up into multiple lines of code, so each line of code is easier to understand, and debug.

Member Avatar for jodzjcm
0
86
Member Avatar for Thoronath

How about a new line 11 1/2: [CODE]if(expression=='q') break; [/CODE] You should have a getchar() in your code, (maybe line 11 3/4ths, to remove the newline that scanf() always leaves behind.

Member Avatar for Thoronath
0
212

The End.