PDA

View Full Version : Can anyone solve this question in C programming Language?



Stella Richards
04-24-2009, 09:11 AM
Hi,

Write code to solve the following problem. Define a function that takes a String as a parameter and returns an integer value. The function need to loop through each character in the input string to find a value of “x”. If a value of “x” is found in the string then return the position within the string where “x” is found else return -*.

Moonbat
04-25-2009, 12:55 AM
Do your own homework please. It's bad enough that people depend on formal schooling to learn how to program, but it's even worse when they don't even learn the concepts they are supposed to. Normally I wouldn't care if someone wanted homework help. But in the programming world, there are already enough bad programmers writing b***y code.

Here's some quick pseudocode to show you what you should do:

int GetPosOfString(char[] input) {
for (int i = 0, i < sizeof(input), i++) {
if (input[i] = "x")
return i;
}
return -*;
}

__DaveY__
05-30-2009, 07:24 PM
Can someone enligten me on what below program does?
I understand getchar and putchar.. but what is this program suppose to do?
I try to put printf on it, but it shows nothing..

can someone explain to me what this program is suppose to do?
It is reading something and assigning to c?

so, if I do, ./a.out filename , will it assign entire filename's content into c?

#include <stdio.h>

/* copy input to output; *st version */

main()
{
int c;

c = getchar();
while (c != EOF) {
putchar(c);
c = getchar();
}
}
-----------------
Keyword Research (http://www.keywordspy.com/keyword-research-tool)
Free Plastics Surgery (http://www.freebeautymakeover.com)
hmm... that's a bit of a strange code there... course than again I dont code...:|

mynamebilal
03-14-2016, 01:04 AM
hi, i am not a guru in c language, but i think that you are trying to convert character data type to integer data type in that case as much i know i think that it is not going to be happen, because character data type value could not be convert in integer !

http://graphicriver.net/item/flat-web-font-icons/*2457*66