not really.
how about you NOT talk like a 12-year-old texting message to your friends during recess, mmkay?
.
and how about you shutting the FUCK up and let me express the way i feel, BASTARD
not really.
how about you NOT talk like a 12-year-old texting message to your friends during recess, mmkay?
.
and how about you shutting the FUCK up and let me express the way i feel, BASTARD
hi, can u plz send ur entire code so we can fix things up greatly,
thnx
hi,
the first thing i noticed is there's no total_sales function, if u can c the total_sales just lemme know, so i wonder how case 2 gonna work, n just @ a 1st sight, there r more prototypes than the cases, maybe if u send us ur source we might help u figuring out whats wrong whith that, plus it will make us a gd exercice,
right guys?
As it’s been previously mentioned that, there are quite a few problems in your code. Which you might have to sit down and think about. I will point you out few error which you have made.
1.The memory allocation for char point word is not right.
Char (*word)[30]; Has to be like this Word = malloc( sizeof (char *[30] ) * 10 ); // Please note you need to do some error checking down, to avoid further problem
2.Reading string through fgets is really a good practice, but at the same time you need to understand the on how to use those function and their parameter list. The fgets function for a void * pointer, but not .void ** pointer. Which means that, the usage of the fgets function should be as follow
fgets( word[i], 30, stdin);
To makes more for easy and, I have written few sample codes which might give you some idea on how to read string in two ways .One is through a Array of char pointer methods and the other one through pointer to pointer methods. Have a look at it. You should get some idea on how to use them.
#include <stdio.h> #include <stdlib.h> void readstring( char (*word)[30] ) { int i; for( i = 0; i < 10; i++ ) fgets( word[i], 30, stdin ); } int main() { char (*word)[30]; int i, num; printf("Enter the number of word you want to sort\n?"); scanf("%d", &num ); word = malloc( sizeof(char *[30]) * 10 ); /* …
printf("how many words u wanna sort\t"); scanf("%ld", &num); getchar(); words=(char *)calloc(num, sizeof(char));
Put the above statements in the main() function and the code should be fine.
EDIT: You'll also adjust the scope of some variables. Do that, too. Post any further problems you have.
i tried it, but im having a break when it goes to "strcmp(words, words[i+1])", it tells me access reading violation or stuff like that
PS: i use visual C
Looks like the variable "num" is not returned to main, the variable "n" is never passed the value of num.
That leaves your sorting function with 0 strings that are being asked to sort. Return num and assign it to n, and see if that doesn't help.
i passed num as a pointer but didnt work, my main problem i guess is when getting the strings, i found a solution using "char words[MAXWORDS][MAXLENGTH]" but i wanna do it "char *words[]",
thnx for ur help
hi everyone,
i was writing an application, with the c language, which asks the user to give the number of strings to sort, and then sort'em, but i had some problems that i can't figure out, would u please help me
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void getting(char *words[], int num);
void sort(char *words[], int n);
int i=0;
int main(int argc, char *argv[])
{
char (*word)[30]=NULL;
int n=0;
getting(word, n);
sort(word, n);
system("pause");
return EXIT_SUCCESS;
}
void getting(char *words[], int num)
{
printf("how many words u wanna sort\t");
scanf("%ld", &num);
getchar();
words=(char *)calloc(num, sizeof(char));
for(i=0; i<num; i++)
{
printf("enter the %ldth word : ", i);
fgets(&words[i], 30, stdin);
}
}
void sort(char *words[], int n)
{
int k=1, sorted=1;
char tmp[30];
do
{
sorted=1;
for(i=0; i<n-k; i++)
{
if(strcmp(words[i], words[i+1])>0)
{
strcpy(tmp, words[i]);
strcpy(words[i], words[i+1]);
strcpy(words[i+1], tmp);
sorted=0;
}
}
k++;
}
while(sorted!=1);
for(i=0; i<n; i++)
printf("%s\n", words[i]);
}
i'm thankful to everyone, it was very helpful:)
hi everyone :), i wanted to create a little program with makes the divisions of the elements of a table i wanted to create a loop which will indicate if there's a number in the table then we should c "the division cannot be made", if not we will get the result,the problem is it doesnt work, u may try it n it wont, i know u will say wht is the utility of such stuff, well im just new to C so im tryin with basics,o_O enough talkin here's my source code
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define n 4
void main()
{
//variables
double table[n]={0};
long no=1,i;
double x=0,d;
//program
for (i=0; i<n; i++)
{
printf("enter the number %d", i);
scanf("%f", &table[i]);
}
printf("gr8\n");
printf("%f", table[0]/table[1]);//this is just to c if it works
for (i=0; i<n; i++)
{
do
{
if(x==0)
no=0;
x=table[i+1];
}
while (x!=0);
}
if (no==0)
printf("the division cannot be made");
else
d=table[0]/table[1]/table[2]/table[3];
printf("the division is %f", d);
system("pause");
}
plz help me solving this, i spent almost a week thinking about it
thank u for ur help
hi everyboody, i am barbie girl :), i know its not a real name but this is how everybody calls me, n i like it, well i hope we gonna learn much from here, c u