Results 1 to 10 of 10
I have my essentials build and all other necessary to develop a k Means for a chosen dataset,
bu unfortunately can't even open the file my code is;
#include <stdio.h>
...
- 05-25-2010 #1Just Joined!
- Join Date
- May 2010
- Posts
- 5
C Help On Ubuntu Latest...
I have my essentials build and all other necessary to develop a k Means for a chosen dataset,
bu unfortunately can't even open the file
my code is;
#include <stdio.h>
int main()
{
FILE *ret;
ret=fopen("~/CENG714/blok16_EO.txt" , "r");
if (ret=NULL);
(
printf("Didn't opened\n");
return 0;
)
}
when i say on terminal it gives me;
cc -c deneme.c:
deneme.c: In function main:
deneme.c:10: error: expected ) before ; token
deneme.c:13: error: expected ; before } token
root:
I can not understand what the hell does that mean... what am i suppose to do please all help me...
Regards
- 05-25-2010 #2Just Joined!
- Join Date
- May 2010
- Posts
- 5
#include <stdio.h>
int main()
{
FILE *ret;
ret = fopen("blok16_EO.txt", "r");
if (ret= NULL){
printf("**** the world!\n");
return 0;
}
}
this one worked but did not give any kind of a answer like i did or did not...
is there a statement like " not = " so that i can check it?
regards
- 05-26-2010 #3Linux User
- Join Date
- Jan 2006
- Posts
- 414
Try something like this:
Now compare that to your code, and spot the problems.Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { FILE *ret; char file[255]; char* home = getenv("HOME"); sprintf(file,"%s/CENG714/blok16_EO.txt",home); ret = fopen(file , "r"); if (ret == NULL) { fprintf(stderr,"Didn't open\n"); return 0; }else{ printf("Opened\n"); } fclose(ret); return 0; }
- 05-26-2010 #4Just Joined!
- Join Date
- May 2010
- Posts
- 5
- 05-26-2010 #5Linux User
- Join Date
- Jan 2006
- Posts
- 414
Here you go, all commented up.
Code:#include <stdio.h> /* stdlib is needed for getenv() */ #include <stdlib.h> int main(int argc, char** argv) { /* file pointer */ FILE *ret; /* file name */ char file[255]; /* get the users home directory */ char* home = getenv("HOME"); /* put the complete home/filename path into file variable */ sprintf(file,"%s/CENG714/blok16_EO.txt",home); /* open the file */ ret = fopen(file , "r"); /* if ret is null the file didn't open */ if (ret == NULL) { /* write a message to standard error */ fprintf(stderr,"Didn't open\n"); /* exit */ return 0; }else{ /* file opened successfully */ printf("Opened\n"); } /* close the file */ fclose(ret); /* exit */ return 0; }
- 05-26-2010 #6- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-26-2010 #7Just Joined!
- Join Date
- May 2010
- Posts
- 5
Thank you guys for all the help;
can you guys tell me how to write a K means program in C, with respect to a dataset which is in text.
I am doing my best to write something, but short time, short learning.
Regards
- 05-30-2010 #8Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Remember, classwork help is not allowed in the forums.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-30-2010 #9Just Joined!
- Join Date
- May 2010
- Posts
- 5
Oh... !
ok, didn't know that sorry.
Regards
- 05-31-2010 #10Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
No problem. The best we can do for classwork type questions is to point you in a direction that will help you find the answers you need. After all, the purpose of class exercises is for you to learn how to do this stuff, and to learn how to find out where resources are that you can use without violating your school's ethical standards.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
