Do you suggest that I use typedef to do this? I have been reviewing my notes and text book, but seems like I should really get involed with this program.
Thank you and take care....
User Profile
Collapse
-
I couldn't get your suggestion to work. I went back to the pointer function and I figure out what was wrong with the I value.
char *p = line; // This was what I had to get correct or I was stuck
do {
printf("Input a positive integer: ");
fgets(line, MAXLINE, stdin);
for (p = line; *p != '\0'; ++p){
if (!isalpha(*p))
error;}
if (error)
printf("\nERROR :...Leave a comment:
-
I have researched strtol function and I see no way to check to see if the string is digital or alpha.
I have been thinking maybe I need to be using pointers. ??
do {
printf("Input a positive integer: ");
fgets(line, MAXLINE, stdin);
for (p = line; *p != '\0'; ++p){
if (!isalpha(*p))
error;}
if (error)
printf("\nERROR : Do it...Leave a comment:
-
Here is what I am thinking about trying....
char line[MAXLINE];
int error, n;
do {
printf("Input a positive integer: ");
fgets(line, MAXLINE, stdin);
error = sscanf(line, "%d", &n) != 1 || n <= 0;
if (error)
printf("\nERROR : Do it again.\n");
for (i = 0; *n != '\0'; n++)}
if (isdigit(*n))
error;}
} while (error);...Leave a comment:
-
Thank you I will try what you suggested, I am hoping that I can get it to work without throwing my computer through a wall.
Thank you again....Leave a comment:
-
What do I scan a string with to determine if it is acceptable or not?...Leave a comment:
-
rwise5 replied to C By Dissection : Accessing Input and Output files accessing student grade averagesin CI will try to include the errors next time. But it wouldn't have helped in this matter, the problem was in the .h file. It seem I had put an colon after a function declaration vice a semi colon. I had also used printf, when I should have used fprintf when dealing with a file.
Thank you for responding....Leave a comment:
-
Help me in developing my print function possible sort function
I have been tasked with finishing the following C program. I need to develop the sort by birthday function and the print grade function. I have been working on the print function for the last week and it seems like everything I try doesn't work. I guess I am not understanding how to deal with structures. Please if someone could please help me out I would appreciate it.
Thank you.
...Code:#include <stdio.h> #include
Last edited by Niheel; Oct 6 '06, 02:33 AM. -
rejecting an non numberic input in C
I was given the following code
char line[MAXLINE];
int error, n;
do {
printf("Input a positive integer: ");
fgets(line, MAXLINE, stdin);
error = sscanf(line, "%d", &n) != 1 || n <= 0;
if (error)
printf("\nERROR : Do it again.\n");
} while (error);
The preceding code works well,... -
rwise5 started a topic C By Dissection : Accessing Input and Output files accessing student grade averagesin CC By Dissection : Accessing Input and Output files accessing student grade averages
I am wondering if someone can help me with the following C programming problem.
I am trying to develop a program dealing with input/output and files .
I am trying to develop a program that creates a file of randomly distributed numbers. The file name is to be entered interactively. Program should use three functions.
I have develop the following modules, but am experiencing errors.
get.c... -
C By Dissection Chapter 12 Exercise 6
I am wondering if someone can help me with the following C programming problem.
I am trying to develop a program dealing with structures and ADTs.
I am trying to develop a program that prints the average for each student in a class. Let an A grade have a value of 4, a B grade have value 3, and so forth.
I have develop the following modules, cl_info.h and main.c, but am experiencing errors.
... -
Thank you, Robrobrob and Banfa. I figure out that I was trying to compile a call function. When I wrote the main program and then called the function it worked. I had actually figured it out before reading the reply from Rob. Thanks again. Oh, I wish I had time to do the other exercise that Rob suggested, but I got to move on with what current assignments I have now. I was just looking for a new suggestions to open my mind. Thanks again.Leave a comment:
-
I am sorry I am not following you. I have my the program book, but there is no examples that talk about switching. I have tried to figure this out but.....???? Here is what I have already.
#include <stdio.h>
void shift(char *p1, char *p2, char *p3, char *p4, char *p5)
{
char c1 = 'A', c2 = 'B', c3 = 'C', c4 = 'D', c5 = 'E';
int tmp = 0;
}
I have prematurely tried to...Leave a comment:
-
C By Dissection chapter 8 exercise 6
Hello, I was wondering if someone could help me with the following?
Write a function that shifts the stored value of five character variables in a circular fashion. Your function should work in the following way. Suppose that c1, c2,...,c5 are variables of type char, and suppose that the values of these variables are 'A' , 'B' , ....' E', respectively. The function call shift (&c1, &c2, &c3, &c4, &c5) should cause... -
Thank you for your offer of help, but I was able to work through it and I have a solution that seems to be working.Leave a comment:
-
C By Dissection Ed. 4, Solution Manual
Does anyone know if there is a solution manual for all the exercises in this book? -
C By Dissection Ed. 4, chapter 7 exercise 5
Hello, I would like to see if anyone can help me in modifying the rock paper scissors program that is one of the exercises in this book. I am thinking that I need to somehow get the information from the compare.c file to come over to the report.c file. The exercise is to get it from just printing "You win" or "You lose" to "You chose ", player_choice "you win." and vice versa for if you lose.
Any help...
No activity results to display
Show More
Leave a comment: