lisedaton 0 Newbie Poster

if i have something like this.... and im getting an error msg on strcpy: " dereferencing pointer to complete type" , what is wrong?

im getting the same msg for most of my pointers and i dont know why, so i decided to try something like this simpler but i still dont see it.... can you help me:::

#include <stdio.h>
#include <malloc.h>
#include <string.h>

struct strs
{
       char x;
};
typedef struct str strs;

int main()
{
strs *hola;
hola= (strs*)malloc(sizeof(strs*)*3);
char names[3][5] = {"DANA",
"RANI","SHIR"};
char *pnames[3];
int i;
for(i=0; i<3; i++)
{
pnames[i] = names[i];
strcpy(hola->x, pnames[i]);
}
system ("pause");
return (0);
}
lisedaton 0 Newbie Poster

hi all!!!!

im trying to do strcmp to a char in a structure and and char* and im getting a msg error: dereferencing pointer to incomplete type....

can somebody explain me what is that and give me an idea how to resolve it?

thanx in advanced!

lisedaton 0 Newbie Poster

H ALL!!

IT CAN BE SAID IM DONE WITH THIS PROGRAM THAT ITS MAKING ME CRAZY... BUT IM HAVING A PROBLEM... (I PAINT THEM RED AND WROTE THE PROBLEM BESIDE IT...)

PLEASE PLEASE
HELP!!!!!!!!!!!!!!!!!!!!!!

THE PROGRAM IS SUPOSSE TO RECIEVE A SENTENCE AND THEN SPLIT IT TO WORDS AND COMPARE THE WORDS AND IF THEY ARE "EQUAL " PRINT THEM!!:..... CANT USE FUNCTIN LIKE STRTROK....

EQUAL DEFINITION:
1--- DOESNT MATTER HOW MANY TIMES A LETTER APPEARS IN THE WORD...
2-- DOESNT MATTER IF THEY ARE WRITTEN IN UPPERCASE OR LOWER CASE...

EXAMPLE...... NANNY , ANY

THANK YOU ALL IN ADVANCED!

#include <stdio.h>
#include <string.h>

char wordA(char sentence[80], int x);
char wordB(char sentence[80], int x);
int endwordA(char sentence[80], int x);
int endwordB(char sentence[80], int x);
void checkword(char word1[80], char word2[80]);

int main()
{
char sentence[80], word1[80], word2[80];
int x=0, endword1=0, endword2=0, counter1, counter2, endwordimp;

printf("Please enter a sentence\n");
gets(sentence);

//running the sentence
while (sentence[x]!='\0')
{
	int i=0;
	int w=1;
		//separating the first word.....
		strcpy(word1, wordA(sentence,x)); /// THIS IS AN ERROR.... BUT I HAVE NO IDEA HOW TO ARRANGE IT... IM SUPOSSE TO SAFE THE VALUE THAT RETURNS FROM THE FUNCTION (CHAR) IN WORD1......
		endword1= endwordA(sentence, x);
		endwordimp = endword1;
		while (i!=w)
		{
			// searching for the second word....
			strcpy(word2, wordA(sentence, endword1)); /// THIS IS AN ERROR.... BUT I HAVE NO IDEA HOW TO ARRANGE IT... IM SUPOSSE TO SAFE THE VALUE THAT RETURNS FROM THE FUNCTION (CHAR) IN WORD1......
			endword2= endwordB(sentence, …
lisedaton 0 Newbie Poster

hi everybody!...
so i have this assigment for monday and im having trouble with it... the program in c should get:

input:
a sentence.....nanny do you have any cheap peach...

and it should print the "same" words...:
nanny any
cheap peach

..they are called "same words when they get the same letter no matter upper or lower case and how many time each letter....

so this is my code i have no idea whats wrong... but can somebody help me fixe it????


thank you alll!

#include <stdio.h>
#include <string.h>

char wordA(char sentence[80], int x);
char wordB(char sentence[80], int x);
int endwordA(char sentence[80], int x);
int endwordB(char sentence[80], int x);
int checkword(char word1[80]);

int main()
{
char sentence[80], word1[80], word2[80];
int x=0, endword1=0, endword2=0, counter1, counter2, endwordimp;

// receives the input from the user
printf("Please enter a sentence\n");
gets(sentence);

//running the sentence
while (sentence[x]!='\0')
{
	int i=0;
	int w=1;
		//separating the first word.....
		word1[x]= wordA(sentence, x);
		endword1= endwordA(sentence, x);
		endwordimp = endword1;
		while (i!=w)
		{
			// searching for the second word....
			word2[x]= wordB(sentence, endword1);
			endword2= endwordB(sentence, endword1);

			//cheking the letters of each word....//....returns the real value of each letter in the word!...
			counter1= checkword(word1);
			counter2= checkword(word2);

			// comparing the words...
			if (counter1==counter2)
			{
				printf ("%s %s", word1, word2);
				endword1= endword2;
				if (sentence[endword2]=='\0' || sentence[endword2+1]=='\0')
				{
					i=w;
					sentence[x]= sentence[endwordimp];
				}
			}
			else 
			{
				endword1= endword2;
				if (sentence[endword2]=='\0' || sentence[endword2+1]=='\0')
				{
					i=w;
					sentence[x]= sentence[endwordimp];
				}
			}
	}
}

system("PAUSE");
return 0; …
lisedaton 0 Newbie Poster

Hi everybody,

so I need to give this huge proyect on monday. Its a proyect that includes another 6 in it and i already did 5 and Im missing one witch im stuck with and I just cant anymore (have been working on it 24/7 since we receive the assigment) PLEASE SOMEBODY HELP!!

Ii need to write a program in c... (without pointers, malloc and all of it.. i can use functions and arrays and strings!...)

the program will receive a sentence and will print the same words in it. the definition for same words is if they have the same latter (no matter how many times each letter) without separating them (uppercase letters= lowercase letters)....

example...

Ana loves her naNa...

will print

Ana naNa
-------------------------------

please help somebody!!!

thanx so much for you time!!!

lisedaton 0 Newbie Poster

Hi, you are simply amazing! and you just save my life!

would you like to explain me just the codes that u used? like what do every one??, Thanx again!!!!....

ps.. I have to do like 5 other things in c, they are done, but im still getting a few mistake... would you like to see them and help me arrange them?

I would really appreciate all your help!!

How Can I thank you????

thanxxx

This is how I got it to work:

def pullNumbers(data):
    NumData, total, x_full = ([], 0, "")
    
    for x in data:
        try:
            int(x)
            x_full = x_full + x
        except:
            if x_full is not "":
                NumData.append(x_full)
            x_full = ""
    if x_full is not "":
        NumData.append(x_full)
    OutNumData = " + ".join(NumData)
    for s in NumData:
        total = total + int(s)
    print "%s = %d" % (OutNumData, total)


pullNumbers(raw_input('Enter a string with some random ints in it'))

I call the function with the text string containing some numbers, if the user put some in (for example: "Give me 4 eggs and I will make 1 cake for all 11 of you" will give you "4 + 1 + 11 = 16")

First set the variables.
Then the for loop divides everything up into strings of length 1, and we try to see if we can get an int out of each one.

the x_full variable is there to catch numbers longer than 10. We only add to the list (NumData) in the except …

lisedaton 0 Newbie Poster

Thank u all so much!!!, you guys are amazing!!!
Im going to try out every thing you guys send!!! will let u knoww!!!!

Thanx again!!!!!!

lisedaton 0 Newbie Poster

hi everybody!!!
I will really appreciate if somebody could help me....
we are working with c and python and the same time and it gets confusing sometimes...

I need to write a program in python tha will receive a string and it will print only the number in the string and the sum of them...

An example of what it should print...

input: 80,45,34
print: 80+ 45+ 34= 159

input: i have 2 bananas and 3 oranges
print: 1+2+3= 6

this is what i got...

data=""
indice=0
number=""
x=0
y= 2
data = input("Please enter a string\n")
print len(data)
while indice < len(data):
        if (data[x]<57 and data[x]>48):
            print ("%s", data [x])
            count += (int(data[x])) + count
            x +=1
            y -=1
            indice +=1
        elif (data[x]>57 and data[x]<48):
            if w!=1:
                w=1
                x +=1
                print ("+")
                indice +=1
            elif w==1:
                w=0
                indice +=1
else:
    print ("=%d", count)

pleasee help!!!!!!!....

lisedaton 0 Newbie Poster

there's no binary pattern representation in C, so you have to use another means to represent the binary pattern from the integer value.

If you can't simply have a function that converts the decimal to the binary pattern and stores it in say a string (char array), then you need to use some bitwise operations, such that you make a copy of first, apply bitwise operations to the copy so the reversed is stored, and compare them.

hi!!! thanx for replying!

im not really allow to use array and bitwise, thats the problem!
any other suggestion???

lisedaton 0 Newbie Poster

hi all!!,

can somebody help me??

I need to do a program that scan a decimal, transform it to binary and check if it is palindrome or not and print "palidrome" or "not palindrome"....

i can only use functions and cant use arrays or anything else!

can somebody help me???
these week i got really sick and i need to give that in and im blank!!... help!

thanx