Forum: C Feb 9th, 2007 |
| Replies: 3 Views: 5,573 Yes. With fopen, SEEK_END and ftell you can determine the size of file and after SEEK_SET read the the whole file with fread.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *... |
Forum: C Jan 26th, 2007 |
| Replies: 2 Views: 914 I'm not shore that I understood your problem.
#if 0
/* you can put here anything and the compiler wouldn't consider it */
#else
/* while this part will be considered */
#endif /* if 0 */ |
Forum: C Nov 22nd, 2006 |
| Replies: 9 Views: 1,679 #include <stdio.h>
#include <string.h>
int one_less(char *);
int main()
{
char s[20];
printf("Type string\n");
scanf("%s", s);
printf("number of changes made is... |
Forum: C Nov 21st, 2006 |
| Replies: 9 Views: 1,679 With something like this:
if ((a[i] > '0') && (a[i] <='9'))
{
a[i] -= 1;
}
In the loop.
One remark about your code. You are not obtaining the string the right way. Read this... |
Forum: C Oct 27th, 2006 |
| Replies: 2 Views: 3,567 Variable answer is float not int. Instead of printf("%d",answer); use printf("%f",answer); instead. Dont use nonstandard func (use them only if your teacher explicitly demanded). You need a getchar... |
Forum: C Oct 25th, 2006 |
| Replies: 12 Views: 1,978 Ok while U're here just to report that the posts order are different for internet explorer and for firefox.
EDIT: is that a bug? |
Forum: C Oct 25th, 2006 |
| Replies: 12 Views: 1,978 WHAT!?!? Okay use this
int main()
{
/* your code going here */
return 0;
} |
Forum: C Oct 25th, 2006 |
| Replies: 12 Views: 1,978 Ah nice didn't know that it exist ([code=c]). :sad: |
Forum: C Oct 25th, 2006 |
| Replies: 12 Views: 1,978 Um you need a main func. Where did you declared the age variable?
do
{
/* stuff */
} while(/*your code going here */);
This is a do while loop, not
do |
Forum: C Oct 25th, 2006 |
| Replies: 12 Views: 1,978 Did you copile this? Use [ CODE] [ /CODE] tags. |
Forum: C Oct 25th, 2006 |
| Replies: 6 Views: 1,597 Also you can do it with string.
len = sprintf(buff, "%d", num);
for (i=0; i<len; i++)
{
printf("%d\n", buff[i] - '0');
}
Where num is in your case 1567. |
Forum: C Oct 20th, 2006 |
| Replies: 14 Views: 4,562 Declare the both globals as locals inside the main func.
int transfer_sequence (char * initial_sequence, char * fix_sequence);
int check_gene (char * fix_sequence);
int main()
{
char... |
Forum: C Oct 19th, 2006 |
| Replies: 14 Views: 4,562 If you using scanf than:
input: G (hit enter) X (hit enter) your output GX
If using getchar
input: GX your output GX.
#include <stdio.h>
int main()
{
int sequencetemp; |
Forum: C Oct 18th, 2006 |
| Replies: 2 Views: 3,062 What part U dont understand? The void pointer? Well void pointer can be used if you are not shore which type will be passed to func compare.
BTW const void must be separated. |
Forum: C Oct 18th, 2006 |
| Replies: 14 Views: 4,562 sorry I didn't read your post carefully. I asume that U must use scanf, so then U must. Ok the problem is your loop. Dont increment x every time.
Check this
for ( x = 0; x < 511; ) { /* x < 511... |
Forum: C Oct 18th, 2006 |
| Replies: 14 Views: 4,562 For obtaining single char you can use getchar which returns int. You can read this (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044652485&id=1043284385) and this... |
Forum: C Oct 8th, 2006 |
| Replies: 2 Views: 774 No it dose not exist. Replace it with
do
{
/* your code going here */
} while(a<b); |
Forum: C Oct 6th, 2006 |
| Replies: 19 Views: 3,887 Convert cust_num to string for example with sprintf.
char buff[MAX];
sprintf(buff, "%d", cust_num);
fputs(buff, fpr);
/* and for fputc */
fputc(cust_num + '0', fpr); /* suposing that cust_num... |
Forum: C Oct 5th, 2006 |
| Replies: 19 Views: 3,887 It means how many of size_t_Size you want to write.
fwrite(buff, sizeof(int), 4, someFile) means you want to write four ints to file. |
Forum: C Sep 30th, 2006 |
| Replies: 10 Views: 2,291 Use code tags (http://www.daniweb.com/techtalkforums/announcement8-3.html) and don't use void main (read this (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044841143&id=1043284376)) |
Forum: C Sep 29th, 2006 |
| Replies: 10 Views: 2,291 With which part do you have problem? Formula for conversion or programming issue? For formulas, read this (http://www.google.com/search?hl=en&lr=&q=formula+temperature+conversion&btnG=Search). For... |
Forum: C Sep 26th, 2006 |
| Replies: 5 Views: 2,567 >error C2061: syntax error : identifier 'scanf'
it means you need ( before scanf.
>I still have to figure out why my average value is coming out wrong.
Did U read my post?
>What would be the best... |
Forum: C Sep 26th, 2006 |
| Replies: 5 Views: 2,567 You are not calculating the total gallons after first gallon input before while, and after finishing the prog you are substacting from total gallons -1. |
Forum: C Sep 11th, 2006 |
| Replies: 3 Views: 1,029 #include <stdio.h>
#include <stdlib.h>
int func();
int main()
{
short mat[3][3],i,j;
for(i = 0 ; i < 3 ; i++) |
Forum: C Sep 1st, 2006 |
| Replies: 3 Views: 1,318 First of all fflush(stdin);won't do the work!
Read this (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044873249&id=1043284392) and this... |
Forum: C Aug 28th, 2006 |
| Replies: 15 Views: 4,282 #include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
void decToBin(int number, int base);
int numOnes = 0;
int main()
{ |
Forum: C Aug 28th, 2006 |
| Replies: 15 Views: 4,282 Ok here it is
for (unsigned int i=0; i<name.size(); i++)
{
cout << name[i] << " binary (";
decToBin(name[i], 2);
cout << ")" << endl;
char tmp[2] = { 0, 0... |
Forum: C Aug 24th, 2006 |
| Replies: 15 Views: 4,282 A litle of help. In your for loop you can make a temp array wich will convert the name[i] to decimal with atoi.
char tmp[2] = { 0, 0 };
tmp[0] = name[i];
answer = atoi(tmp);
Figure this out |
Forum: C Aug 24th, 2006 |
| Replies: 15 Views: 4,282 This is illegal. What did you want with this line? |
Forum: C Jun 29th, 2006 |
| Replies: 10 Views: 2,649 #include<stdio.h>
#include<stdlib.h>
main()
{
FILE *fp;
char buffer[]="STEPHEN"; |
Forum: C Jun 28th, 2006 |
| Replies: 9 Views: 1,243 AH yes you are totaly right but I used it becouse the string length is very short in this case. |
Forum: C Jun 28th, 2006 |
| Replies: 9 Views: 1,243 Don't understand what you trying to tell (my english is far from perfect) but whats wrong with strlen. You mean don't use it in for loop? |
Forum: C Jun 28th, 2006 |
| Replies: 9 Views: 1,243 #include <string.h>
#include <stdio.h>
int main()
{
int num = 123;
int i, result;
char buff[11], temp[2] = {0, 0};
sprintf(buff, "%d", num); |
Forum: C Jun 28th, 2006 |
| Replies: 9 Views: 1,243 Here is an idea. Convert to char * |
Forum: C Jun 24th, 2006 |
| Replies: 11 Views: 3,884 A little bug just change the Exit func to
void * Exit(void * ptr)
{
char c;
while (1)
{
scanf("%c", &c);
if ( c == 'e') |
Forum: C Jun 24th, 2006 |
| Replies: 11 Views: 3,884 This is just an idea how can solve your problem
#include "stdio.h"
#include "pthread.h"
pthread_t threadEvent;
unsigned char breakLoop = 0;
void * Exit(void * ptr) |