B
Bill Cunningham
I was only following advice. But one's advice is another's vice.Bill Cunningham said:This indenting is the result of indent -kr. It is not my indenting.
Bill
I was only following advice. But one's advice is another's vice.Bill Cunningham said:This indenting is the result of indent -kr. It is not my indenting.
Chris M. Thomasson said:I still think he programs for Microsoft!:
http://groups.google.com/group/comp.lang.c/msg/0815601591d605fd
Okay... Let the cat out of the bag Bill! Your are Gates Right?
Gates has a house right on the north shore of Lake Tahoe, I live in South
Lake Tahoe. Can I visit you?
Anand Hariharan said:argv can be declared either as int **argv or as int *argv[].
Clearly, you meant to say " ... as char **argv or as char *argv[]."
Bill Cunningham said:[snip]
After dozens of messages regarding indenting, you still produce
abominations like this. You managed to hit the space bar four times
for the if statement. Is counting to four twice that difficult for
the puts statement.
[snip]
This indenting is the result of indent -kr. It is not my indenting.
Bill Cunningham said:Assuming gcc & bash, try:
$ gcc foo.c 2>&1 | less
(Recommended options such as -Wall suppressed for clarity.)
Ok that works. Here is my compiler's errors. I have rewritten everything
and since this is non-production code I am using the ex macro to represent
exit(EXIT_FAILURE).
gcc: 2: No such file or directory
p.c: In function `main':
p.c:11: error: syntax error before '{' token
p.c: At top level:
p.c:17: error: conflicting types for 'x'
p.c:16: error: previous declaration of 'x' was here
p.c:17: error: `argv' undeclared here (not in a function)
p.c:17: error: initializer element is not constant
p.c:17: warning: data definition has no type or storage class
p.c:18: error: conflicting types for 'y'
p.c:16: error: previous declaration of 'y' was here
p.c:18: error: initializer element is not constant
p.c:18: warning: data definition has no type or storage class
p.c:19: error: syntax error before "if"
p.c:22: error: syntax error before string constant
p.c:22: error: conflicting types for 'fprintf'
p.c:22: note: a parameter list with an ellipsis can't match an empty
parameter name list declaration
p.c:22: error: conflicting types for 'fprintf'
p.c:22: note: a parameter list with an ellipsis can't match an empty
parameter name list declaration
p.c:22: warning: data definition has no type or storage class
Bill
Bill Cunningham said:Assuming gcc & bash, try:
$ gcc foo.c 2>&1 | less
Here's a reposting of the source.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define ex exit(EXIT_FAILURE)
int main (int argc, char *argv[]) {
if (argc!=4) {
puts("print usage error");
ex;
}
if (isalpha(argv[1]) || isalpha(argv[2]) {
puts("print non alpha allowed");
ex;
}
FILE *fp;
double x,y;
x=strtod(argv[1],NULL);
y=strtod(argv[2],NULL);
if (fp=fopen(argv[3],"a"))==EOF) {
puts("fopen error");
}
fprintf(fp,"%.2f",x,y);
if (fclose(fp))==EOF) {
puts("fclose error");
}
return 0;
}
Bill
You left me kinda scratching my head there on that one Keith. I'd neverYes. (*blush*)
Richard said:Here's a reposting of the source.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define ex exit(EXIT_FAILURE)
int main (int argc, char *argv[]) {
if (argc!=4) {
puts("print usage error");
ex;
}
if (isalpha(argv[1]) || isalpha(argv[2]) {
puts("print non alpha allowed");
ex;
}
FILE *fp;
double x,y;
x=strtod(argv[1],NULL);
y=strtod(argv[2],NULL);
if (fp=fopen(argv[3],"a"))==EOF) {
puts("fopen error");
}
fprintf(fp,"%.2f",x,y);
if (fclose(fp))==EOF) {
puts("fclose error");
}
return 0;
}
I needed a good laugh so I complied the rubbish above. It took 10
seconds to get it to compile with only warnings.
Yes. (*blush*)
You left me kinda scratching my head there on that one Keith. I'd never
seen int *argv[] before.
But what do I know.
Why republish horribly broken code when you aren't going to attempt to
correct it?
That it compiles is beside the point.
santosh said:Richard said:Here's a reposting of the source.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define ex exit(EXIT_FAILURE)
int main (int argc, char *argv[]) {
if (argc!=4) {
puts("print usage error");
ex;
}
if (isalpha(argv[1]) || isalpha(argv[2]) {
puts("print non alpha allowed");
ex;
}
FILE *fp;
double x,y;
x=strtod(argv[1],NULL);
y=strtod(argv[2],NULL);
if (fp=fopen(argv[3],"a"))==EOF) {
puts("fopen error");
}
fprintf(fp,"%.2f",x,y);
if (fclose(fp))==EOF) {
puts("fclose error");
}
return 0;
}
I needed a good laugh so I complied the rubbish above. It took 10
seconds to get it to compile with only warnings.
<snip>
Why republish horribly broken code when you aren't going to attempt to
correct it?
That it compiles is beside the point.
Bill Cunningham said:Non production code!
Yes that's right Richard. Non production meant to be used only by me or I
would use exit(EXIT_FAILURE) everytime it is to be used and not the #define
ex macro.
Bill Cunningham said:You left me kinda scratching my head there on that one Keith. I'd neverYes. (*blush*)
seen int *argv[] before. But what do I know.
Bill said:Why republish horribly broken code when you aren't going to attempt
to correct it?
That it compiles is beside the point.
This has been re-written Santosh. [ ... ]
Bill said:Santosh or anyone,
isalpha takes as its parameter an int. If it is testing to see if
something is a char it doesn't make sense to me to take an int. What
am I not seeing?
http://www.cppreference.com/stdstring/isalpha.html
This is a pretty good reference page. char **argv is the parameter I
am passing to main. isalpha is not going to take this.
Right.
It wants an
int. Am I going to have to use atoi in here somewhere just to test if
something is a char or not?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.